Server Error in '/customimpression' Application.

ExecuteReader requires an open and available Connection. The connection's current state is closed.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidOperationException: ExecuteReader requires an open and available Connection. The connection's current state is closed.

Source Error:


Line 28: 
Line 29:             cmd = new SqlCommand(sql, conn);
Line 30:             rs = cmd.ExecuteReader();
Line 31:             if (rs.Read()) {
Line 32:                 endDate = rs["EndTime"].ToString();

Source File: C:\inetpub\wwwroot\customimpression\SessionAttributes.cs    Line: 30

Stack Trace:


[InvalidOperationException: ExecuteReader requires an open and available Connection. The connection's current state is closed.]
   System.Data.SqlClient.SqlCommand.ValidateCommand(String method, Boolean async) +684
   System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method, TaskCompletionSource`1 completion, Int32 timeout, Task& task, Boolean& usedCache, Boolean asyncWrite, Boolean inRetry) +156
   System.Data.SqlClient.SqlCommand.RunExecuteReader(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, String method) +84
   System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior, String method) +207
   System.Data.SqlClient.SqlCommand.ExecuteReader() +142
   SessionAttributes.getSessionAttributes(String& sessionCode) in C:\inetpub\wwwroot\customimpression\SessionAttributes.cs:30
   customimpression.productdetails.Page_Load(Object sender, EventArgs e) in C:\inetpub\wwwroot\customimpression\productdetails.aspx.cs:40
   System.Web.UI.Control.OnLoad(EventArgs e) +108
   System.Web.UI.Control.LoadRecursive() +90
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1533


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4494.0