I am trying to connect to an MS SQL server residing on our local network but always
getting back the message of "System.Data.SqlClient.SqlException(0x80131904): A network-related or instance-specific error occurred...".
I can connect to the server with TOAD for SQL SERVER by Windows authentication.
I copied the code below.
What did I do wrong.
private void button1_Click(object sender, EventArgs e)
{
SqlConnection conn = new SqlConnection("server=\\AAA"
try
{
conn.Open();
label1.Text = "Connection OK";
conn.Close();
}
catch(Exception ex)
{
label1.Text = ex.ToString();
}
}
Thanks,
Tamas

Javeed M ShaikhRank #839 · 2.7K reputationPosted Apr 20, 2013, 3:20 PM EDT
SqlConnection conn = new SqlConnection("Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;");
Satyapriya NayakRank #47 · 31.5K reputationPosted Apr 20, 2013, 7:14 PM EDT
Tamas Szigeti15 reputationPosted Apr 20, 2013, 9:46 PM EDT
"Data Source=AAA;Initial Catalog=teszt;Integrated Security=True".
Why does not work it with this line of code, then?
SqlConnection conn = new SqlConnection("Server=AAA";"Database=teszt;Trusted_Connection=True");