开发者

Why do i get "An attempt to attach an auto-named database for file ..." exception

I create a database in SQL Server 2008 Express (Advanced). Then i have a connection stri开发者_开发知识库ng in my C# using 'SharpDevelop' IDE, Version : 3.2.0.5777, .NET Version : 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" />

When application tries to connect to this database (SpringTesting), i get this exception

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.

I am not doing anything related to ASP.NET. Any ideas on how to prevent this ?

Thanks, Chak.


The connection string that you are using is telling SQL to attach the database. Since you have already created the database it is complaining.

Change the connection string to connect to the database you have created:

Server=.\SQLEXPRESS; Initial Catalog=SpringTesting;Integrated Security=True;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜