尝试附加自动命名的数据库错误 [英] An Attempt to attach an auto-named database Error

查看:17
本文介绍了尝试附加自动命名的数据库错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试为文件 C:UsersJohndocumentsvisual studio 2010ProjectsPASPASinDebug//PatAddSys.mdf 附加自动命名的数据库失败.具有相同名称的数据库存在,或者无法打开指定的文件,或者它位于 UNC 共享上."

"An attempt to attach an auto-named database for file C:UsersJohndocumentsvisual studio 2010ProjectsPASPASinDebug//PatAddSys.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share."

这里出了什么问题?我的路径有正确的代码(我认为)但这里仍然发生此错误是我的数据库路径

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";

这是我的数据库的位置

推荐答案

尝试将连接字符串中的用户实例属性设置为 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屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆