title: Not able to connect to SQL, ERROR = ServerVersion 'conn.ServerVersion' threw an exception of type 'System.InvalidOperationException'
body: <p>I'm getting an error that I can't find an answer for anywhere online. It says </p>
  
  <blockquote>
    <p>ServerVersion 'conn.ServerVersion' threw an exception of type 'System.InvalidOperationException'</p>
  </blockquote>
  
  <p>I've blocked out some words as not to compromise our data. It's not even making the connection.</p>
  
  <p><img src="https://i.stack.imgur.com/wkXRc.jpg" alt="Screenshot"></p>
  
  <p>This connection string works in previous application version (Visual Studio 2012, .NET Framework 4.5.2 using Microsoft.Practices.EnterpriseLibrary.Data.Sql) so I know it's not the credentials.  We are re-writing the old application so the new one is using Visual Studio 2015, .NET Framework 4.5.2, and System.Data.SqlClient.</p>
  
  <p>Here is the <code>web.config</code> connection string:</p>
  
  <pre><code>&lt;connectionStrings&gt;
  &lt;add name="DataConnection" 
       connectionString="Data Source=mydatabaseserver\tst1;Initial Catalog=LeaseData;Persist Security Info=True;User ID=myID;Password=mypassword" 
       providerName="System.Data.SqlClient" /&gt;
  &lt;/connectionStrings&gt;
  </code></pre>
  
  <p>This is my c# code calling to the database using my connection string that is available in the <code>web.config</code>.</p>
  
  <pre><code>public static DataTable ContractDetails(string contractID, string pointOfContact)
      {
          string connString = ConfigurationManager.ConnectionStrings["DataConnection"].ConnectionString;
          using (SqlConnection conn = new SqlConnection(connString))
          {
              try
              {
                  if (connString.Length &gt; 0)
                  {
                      using (SqlCommand cmd = new SqlCommand("spNameOfStoredProcedure"))
                      {
                          using (SqlDataAdapter da = new SqlDataAdapter())
                          {
                              cmd.CommandType = CommandType.StoredProcedure;
                              cmd.Connection = conn;
                              da.SelectCommand = cmd;
  
                              cmd.Parameters.AddWithValue("@ContractID", contractID);
                              cmd.Parameters.AddWithValue("@PointOfContact", pointOfContact);
                              cmd.ExecuteNonQuery();
  
                              using (DataTable dt = new DataTable())
                              {
                                  da.Fill(dt);
                              }
                          }
                      }
                  }
              }
              catch (SystemException)
              {
  
              }
          }
  </code></pre>
  
  <p>Let me know if there is anything else that would be helpful in solving this issue!  </p>
  
  <p>Thanks!</p>