title: Sql connection-string for localhost server
body: <p>I am newbie in this .NET and please don't mind in answering my simple question.
  I am trying to write a windows application, where in I am using a localhost SQLserver for database.</p>
  
  <p>I need to know what is the exact connection string for my localhost, if my server name looks like as below:</p>
  
  <blockquote>
    <blockquote>
      <p>Data Source=HARIHARAN-PC\SQLEXPRESS;Initial Catalog=master;Integrated Security=True</p>
    </blockquote>
  </blockquote>
  
  <p>should i need to give this same as connection string, or is something wrong in this syntax.</p>
  
  <p>whn i try to open my connection.
  I am seeing error in opening connection.</p>
  
  <p>How the format of connection string should be? any one please guide me.</p>
  
  <p>I tried like this :</p>
  
  <pre><code> private void button1_Click(object sender, EventArgs e)
      {
          string str = "Data Source=HARIHARAN-PC\SQLEXPRESS;Initial Catalog=master;Integrated Security=True" ; 
          SqlConnection con = new SqlConnection(str);
          SqlCommand cmd = new SqlCommand();
          SqlDataReader r;
  
          cmd.CommandText = "SELECT * from Table1";
          cmd.CommandType = CommandType.Text;
          cmd.Connection = con;
  
          con.Open();
  
          r = cmd.ExecuteReader();
  
          con.Close();
  
  
      }
  </code></pre>
  
  <p>This code errors out at con.Open();</p>