1
我試圖運行一個程序,它從一個遠程SQL Server中獲取數據,但是當我運行該程序的調試器說:「錯誤定位服務器/實例指定」C# - 錯誤26-定位服務器/實例指定
我搜索了網頁和Stack Overflow,並嘗試了很多東西,但沒有成功!
我在這裏做錯了什麼?
private void txtsearch_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("Server=.\\MSSQLSERVER;AttachDbFilename = C:\\Program Files\\Microsoft SQL Server\\MSSQL11.MSSQLSERVER\\MSSQL\\DATA\\Education.mdf; Database= education;Trusted_Connection=Yes;");
DataTable dt = new DataTable();
SqlDataAdapter SDA = new SqlDataAdapter("Select * From Education Where NationalKey "+ txtNationalKey.Text, conn);
SDA.Fill(dt);
dataGridView1.DataSource = dt;
}
我試過MSSQL11,SQL Express和許多其他格式的字符串。我也打開了UDP端口1434,TCP端口1433和7200。