3
Answers

MSSql server connection failed

Tamas Szigeti

Tamas Szigeti

11y
944
1

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)