sql-server
  • sql-server-express
  • 2010-10-22 33 views 1 likes 
    1

    我在SQL Server 2008 Express(Advanced)中創建了一個數據庫。然後,我有一個連接字符串中使用「SharpDevelop的」 IDE版本我的C#: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相關的任何事情。有關如何防止這種情況的任何想法?

    謝謝, 澤。

    回答

    2

    您正在使用的連接字符串是告訴SQL連接數據庫。由於您已經創建了它抱怨的數據庫。

    更改連接字符串連接到您所創建的數據庫:

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

    謝謝,但我做到了,並得到了同樣的錯誤。網上有這個問題的答案,但他們有太多的東西,我們需要嘗試! – Chakra 2010-10-23 12:04:47

    +0

    我似乎通過重疊安裝而搞砸了。我也搞亂了一些安裝。於是我終於從註冊表中刪除了所有SQL組件(http://www.gilham.org/Blog/Lists/Posts/Post.aspx?List=aab85845-88d2-4091-8088-a6bbce0a4304&ID=190),並刪除了SQL Server程序文件中的文件夾。配置選項不會從啓動程序中去。無論如何,在刪除我可能找到的所有SQL痕跡(也可以使用msiinv和smartmsizap進行很好的測量)之後,我設法重新安裝了SQL Server Express 2005。你的連接字符串工作。 – Chakra 2010-10-26 06:41:02

    +0

    http://blogs.msdn.com/b/astebner/archive/2005/09/13/465401.aspx這也有幫助 – Chakra 2010-10-26 07:16:56

    相關問題