2009-02-06 135 views
1

有一次我被告知,不必讓我的主機註冊一個SQL Server數據庫文件+用戶名/密碼,而是可以將我的MDB文件放入我的網站的APP_DATA並直接連接到它。我該怎麼做呢?SQL Server 2005和APP_DATA

我試着使用SqlConnection的連接嚮導,並設置數據源 :Microsoft SQL Server數據庫文件(SqlClient中) 數據庫文件名:路徑在我的App_Data文件夾不存在的文件。 身份驗證:(同時嘗試Windows和SQL服務器)

我點擊確定,在這一點上,我被問到是否希望創建文件,我選擇「是」。然後,我遇到此消息:


微軟的Visual Studio


A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified)


OK


我有安裝SQL Server 2005。有什麼我失蹤?

回答

2

我希望你的意思是.MDF文件?

文件名的完整路徑位於連接字符串中。例如:

Server = localhost; AttachDbFilename = c:\ mydbfile.mdf; Database = dbname; Trusted_Connection =是;

+0

是的,密度板:-) 但是,爲什麼這個連接對話框失敗,這個錯誤?如果我預計它能夠正常工作,那麼肯定這個對話框至少應該成功地創建MDB文件。 – 2009-02-06 14:49:56

1

副手,我想他們在談論的是MS SQL Express。