Q: ServerVersion = 'cmd.Connection.ServerVersion' threw an exception of type 'System.InvalidOperationException' I noticed that some others also have had the same issue but couldn't able to find a solution. My ASP.NET application was working perfectly and suddenly experienced this. It's not throwing any exceptions but the stored procedures become not returning values as previous. When I debug the program noticed that there is a problem with my SqlCommand.
SqlCommand cmd = new SqlCommand();
cmd.Parameters.AddWithValue("@UserID", Convert.ToInt64(Request.QueryString["UserID"]));
DataTable dtuser = db.GetDataTable(cmd, "sp_GetUserbyUserId");

I added a watch and had a look on cmd. Connection's ServerVersion property showing above message and the Message property saying "Invalid operation. The connection is closed.". I'm thinking my SPs are not functioning because of this. What would be the issue here? 
Recently what I did change in the web.config is just adding new field under <appSettings/>
Edit
Below is my DBHandler class method which is called by above db instance.
public class DBHandler
{
    private string connectionString = "";
    public DBHandler()
    {    
        connectionString = WebConfigurationManager.ConnectionStrings["myConString"].ConnectionString.ToString();
    }

    public DataTable GetDataTable(SqlCommand sqlcmdWithParameters, string CommandText)
        {
            DataTable dtReturn = new DataTable();
            SqlDataAdapter sqlda = new SqlDataAdapter(sqlcmdWithParameters);

            using (SqlConnection sqlcon = new SqlConnection(connectionString))
            {
                sqlcmdWithParameters.Connection = sqlcon;
                sqlcmdWithParameters.CommandType = CommandType.StoredProcedure;
                sqlcmdWithParameters.CommandText = CommandText;
                try
                {
                    DataSet ds = new DataSet();
                    sqlda.Fill(ds, "Table");
                    dtReturn = ds.Tables["Table"];
                }
                catch (Exception ex)
                {
                   //Handling Exceptions
                }
            }
            return dtReturn;
        }
}

My connection string in the Web.config is as follows
<connectionStrings>    
    <add name="myConString" connectionString="Data Source=xxx.xxx.x.x;Initial Catalog=myDB;User ID=myId;Password = myPWD" providerName="System.Data.SqlClient" />
  </connectionStrings>


A: I just had the same error.  On my machine while I had Visual Studio 2013 Open, I uninstalled and re-installed my Oracle Data provider.
After Oracle was re-installed I ran my otherwise working asp.net application and started getting this error when trying to, not create, but open a Database connection.
After closing visual Studio and reopening it, the error went away.  Perhaps something about my "ServerVersion" was invalidated and then reset when I reopened Visual Studio.
