title: C# SQL Server Class Connection String from a text file [error Instance failure]
body: <p>I save connection string in a text file, like this :</p>
  
  <p>koneksi.txt</p>
  
  <pre><code>Data Source=GGL-TBGIT-PC02\\SQLEXPRESS; Initial Catalog=db_timbangan;user=sa;password=GGL654321
  </code></pre>
  
  <p>and this  my class connection</p>
  
  <pre><code>class Koneksi
  {
      public System.Data.SqlClient.SqlConnection GetConn()
      {
          string path;
          TextReader tr = new StreamReader(@"D:\PROJECT\2.0 TIMBANGAN\TIMBANGAN\koneksi.txt");
          path = tr.ReadLine();
          System.Data.SqlClient.SqlConnection conn = new System.Data.SqlClient.SqlConnection();            
          conn.ConnectionString = path;
          return conn;
      }
  }
  </code></pre>
  
  <p>this my login</p>
  
  <pre><code>Koneksi konn = new Koneksi();
      public Login()
      {
          InitializeComponent();
          this.AcceptButton = button1;
      }
  
      private Boolean statusLogin(string username, string password)
      {
          System.Data.SqlClient.SqlConnection conn = konn.GetConn();
          conn.Open();
          string sql = "select * from tbl_login where username='" + username + "' AND password='" + password + "'";
          SqlCommand command = new SqlCommand(sql, conn);
          SqlDataReader reader = command.ExecuteReader();
  
          while (reader.Read())
          {
              if (reader["username"].ToString() == username &amp;&amp; reader["password"].ToString() == password)
              {
  
                  return true;
              }
          }
          conn.Close();
          return false;
      }
  </code></pre>
  
  <p>when I tried to log in, the error Instance failure at <strong>conn.Open()</strong></p>
  
  <p>how to fix it ?</p>