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
Tamas SzigetiPosted Apr 21, 2013, 1:46 AM
"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");
Satyapriya NayakPosted Apr 20, 2013, 11:14 PM
Javeed M ShaikhPosted Apr 20, 2013, 7:20 PM
SqlConnection conn = new SqlConnection("Server=myServerAddress;Database=myDataBase;Trusted_Connection=True;");