I am wiorking on a web application when i click on to fetch data from database i get the following error:
ExecuteReader requires an open and available Connection. The connection's current state is closed.
ExecuteReader requires an open and available Connection. The connection's current state is closed.
I declare my connection on a seperate class as the following:
public Database()
{
valid = false;
using (connection = new SqlConnection(connectionString))
{
connection.Open();
}
}
Where i get the error:
and i call it from a WebForm. Why do i get this error when the connection is already open (I used to use odbc connection and it works fine, however the SqlConnection is not working)
What is the reason?