以下代碼在執行過程中出現錯誤。數據庫連接出錯
string connectionString = "Data Source=D:\\Base.sdf;Persist Security Info=False";
SqlConnection sqlConnection = new SqlConnection(connectionString))
sqlConnection.Open();
的錯誤是:
A network-related or instance-specific error occured 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 not configured to allow remote connections. (provider:SQL network Interfaces, error: 26 - Error locating Server/Instance Specified)
我試過SqlCeConnection
代替SqlConnection
但是,編譯器無法找到與一流的圖書館。
請幫忙解決這個問題。
- 的操作系統:Windows 7
- 工具:微軟的Visual Studio 2010
- 語言:C#
'.sdf'是** **肯定一個SQL Server **精簡版本**(CE)數據庫 - 因此您需要確保安裝必要的程序集才能使SqlCeConnection工作。這將** **不適用於'SqlConnection'! –
我需要安裝什麼組件? – Nurlan
你需要SQL Server CE運行庫的東西 - 查看[Everything SQL Server Compact](http://erikej.blogspot.ch/) - 這個網站有大量的解釋,教程,how-tos等,並且肯定也會有有關需要安裝的信息以及從哪裏獲取信息 –