一个尝试附加自动命名的数据库错误 [英] An Attempt to attach an auto-named database Error
问题描述
附加自动命名的数据库文件C尝试:\用户\约翰\文档\ Visual Studio 2010的\项目\ PAS \ PAS \斌\调试// PatAddSys.mdf失败具有相同名称的数据库。是否存在,或者指定的文件无法打开,或它位于UNC共享。
"An attempt to attach an auto-named database for file C:\Users\John\documents\visual studio 2010\Projects\PAS\PAS\bin\Debug//PatAddSys.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share."
什么是错在这里?我有正确的code是我路(我认为),但仍然出现这个错误,这里是我的数据库路径
What's wrong here? I have the correct code for my path ( I think) but still this error occurs here is my database path
private string dbPath = Application.StartupPath + "//PatAddSys.mdf";
下面是我的数据库的位置
Here's the location of My Database
推荐答案
尝试将用户实例属性在连接字符串为true。你需要把它添加到您的连接字符串:
Try setting the User Instance property in your connection string to true. You need to add this to your connection string:
User Instance=True
也只是可以肯定的再次检查你的数据库服务器,因为它可能已经包含具有相同名称的数据库。
Also just to be sure check again your database server as it might already contain a database with the same name.
希望有所帮助。
这篇关于一个尝试附加自动命名的数据库错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!