gpt4 book ai didi

vb.net - 将表适配器添加到数据集时出错

转载 作者:行者123 更新时间:2023-12-02 04:56:15 25 4
gpt4 key购买 nike

我正在 Vb.net 中开发一个 winforms 应用程序当我尝试将 tableadapter 添加到现有数据集时,我收到错误:

Failed to open a connection to the database. "An attempt to attach an auto-named database for file ###Filelocation### failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share." Check the connection and try again.

这个相同的数据集有 2 个使用相同数据连接的其他表适配器(因为我正在选择已经存在的数据连接),它们工作正常此连接正在使用应用程序连接字符串:

Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\test.mdf;Integrated 
server=localhost;user id=root;password=password;database=testuser;persistsecurityinfo=True

每次我在弹出的第一个窗口中选择数据连接器时,都会弹出此错误。为什么会这样

附加信息:使用不同的计算机将其他 2 个表适配器添加到此数据集这是一个 mysql 连接

最佳答案

我在 MSDN 论坛上找到了这篇帖子:

An attempt to attach an auto-named database ....\aspnetdb.mdf failed

建议之一是先生DonBoitnott正确地说,添加 User Instance=True;但是Luke A 也发布了另一个建议.

"For the record, not one single error message given to me during the course of trying to fix this was relevant to the actual problem. Upon first receiving "An attempt to attached an auto-named database..." I looked online for every suggestion I could find: use an absolute path to the MDF, reorder TCP/IP and named pipes in the server configuration, disable/enable UserInstance (depending on where you looked), change security settings, reconfigure authentication, give specific login credentials.

None of these worked. All of these led to different vague/ambiguous error messages, which led to another problem which required a solution which led back to the original error message... an endless loop of problems, completely unrelated to what was actually wrong.

_Also, posts about setting correct permissions on the App_Data folder are deceptive, as they imply the default permissions were not sufficient for SQL Express (in fact, they are). The whole point of this VS environment is that you can develop a web application and plop it right onto an IIS/SQLExpress setup and have it work. This makes the applications more portable (within IIS, of course) and secure. Of course, everything configuration-related has been obfuscated enough to make it several orders of magnitude more difficult than it has to be."_

因此:尝试将 Initial Catalog=uniquenamehere 添加到您的连接字符串中。

尽管他说 “...其中‘uniquenamehere’是您项目的某个名称。”,请尝试将 uniquenamehere 替换为实际名称表所在的数据库的名称。

关于vb.net - 将表适配器添加到数据集时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21949119/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com