title: SQL Server Database Connection C# ASP.NET
body: <p>To initialize the connection string, it needs to be a static string. Why that happens?</p>
  
  <pre><code>using System.Data.SqlClient;
  
  namespace CDemoLib
  {
      public class Connecting
      {
          static string conString = @"connection string here";
  </code></pre>
  
  <p>Also when I am trying to open a connection using the <code>conn.Open()</code>am getting an error saying that </p>
  
  <blockquote>
    <p>The name conn.Open() does not exist in the current context</p>
  </blockquote>
  
  <p>Why that error occurs ?</p>
  
  <pre><code>using System.Data.SqlClient;
  
  namespace CDemoLib
  {
      public class Connecting
      {
           static string conString = @"connection string here";
  
      SqlConnection conn = new SqlConnection(conString);
      conn.Open();
  </code></pre>