Мой код выглядит следующим образом:Ошибка при подключении к SQL Server с помощью C#
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)
Ха, я получил ответ первым, но вы получили голоса? :) Ну, может быть, в следующий раз ... –
Похоже, я опоздал на несколько секунд.Я проголосовал за вас :) – Shoban