Hi All,
public string execCount(string query)
{
string CS = ConfigurationManager.ConnectionStrings["DBCS"].ConnectionString;
using (SqlConnection con = new SqlConnection(CS))
{
SqlCommand cmd = new SqlCommand(query,con);
cmd.Connection = con;
string count = cmd.ExecuteScalar().ToString();
return count;
}
}
It is giving me error saying that
ExecuteScalar requires an open and available Connection. The connection's current state is closed. What is the error here?
Thanks