MSSql server connection failed

Apr 20 2013 4:19 PM

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"

                                    + "trusted_connection=yes;"

                                    + "database=TESZT;connection timeout=10");

          

           try

           {

           conn.Open();

           label1.Text = "Connection OK";

           conn.Close();

           }

           catch(Exception ex)

           {

               label1.Text = ex.ToString();

           }

       }


Thanks,

Tamas


Answers (3)