我試圖連接到本地數據庫(我的計算機中的「.db」文件),但當我嘗試打開連接時出現錯誤。我正在使用Sharp Develop(我不能使用Visual Studio的連接嚮導來獲取連接字符串)。使用SqlConnection連接到SQLite時出錯,爲什麼?
String connectionString = @"Data Source=C:\Users\Adl\Documents\BBDD_Test.db";
var c = new SqlConnection(connectionString);
c.Open();
錯誤:
System.Data.SqlClient.SqlException: 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)
發生了什麼事?
什麼是你的數據庫格式? SQLite的? – Pikoh
數據庫格式是SQLite 3 – Ralk
然後你不能使用'SqlConnection',這是Sql Server。你需要下載[System.Data.Sqlite](https://system.data.sqlite.org/index.html/doc/trunk/www/index.wiki)並使用它來代替 – Pikoh