我在SQL Server 2008 Express (Advanced)中创建了一个数据库。然后在我的C#中有一个使用'SharpDevelop‘集成开发环境的连接字符串,版本: 3.2.0.5777,.NET版本: 2.0.50727.3615
<add name="ConnectionString" connectionString='Data Source=.\SQLEXPRESS;AttachDbFilename="D:\Program Files\Microsoft SQL Server\MSSQL10.SQLEXPRESS\MSSQL\DATA\SpringTesting.mdf";Integrated Security=True;Connect Timeout=30;User Instance=True' providerName="System.Data.SqlClient" />当应用程序尝试连接到这个数据库(SpringTesting)时,我得到了这个异常
An attempt to attach an auto-named database for file E:\STS_Client\SpringEfficiency\TestProject1\bin\Release\aspnetdb.mdf failed. A database with the same name exists, or specified file cannot be opened, or it is located on UNC share.我没有做任何与ASP.NET相关的事情。你有什么办法防止这种情况发生吗?
谢谢,Chak。
发布于 2010-10-23 00:56:10
您正在使用的连接字符串正在告诉SQL附加数据库。因为您已经创建了数据库,所以它会报错。
更改连接字符串以连接到已创建的数据库:
Server=.\SQLEXPRESS; Initial Catalog=SpringTesting;Integrated Security=True;https://stackoverflow.com/questions/3998972
复制相似问题