我的代碼如下:錯誤嘗試使用C#來連接到SQL Server
string constring = "Data Source=132.186.127.169"+ "Initial Catalog=CadPool1;" + "Integrated Security=True";
SqlConnection con;
con = new SqlConnection(constring);
con.Open();
string query="SELECT * from CadPoolProjectTable1";
SqlCommand cmd = new SqlCommand(query, con);
cmd.ExecuteNonQuery();
MessageBox.Show("selected");
con.Close();
我得到的錯誤在該行con.Open();
。錯誤是:
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: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
哈我在第一次得到答案,但你得到的票? :)哦,也許下次... – 2011-01-27 06:51:32
看起來我遲到了幾秒。我投了你的票:) – Shoban 2011-01-27 06:54:02