Server Error in '/' Application.

ExecuteScalar 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: ExecuteScalar requires an open and available Connection. The connection's current state is closed.

Source Error:


Line 53:         Dim Cacmd As New OleDbCommand(Sql, Conn)
Line 54:         OpenConn()
Line 55:         Dim PgCount As Integer = Cacmd.ExecuteScalar
Line 56:         CloseConn()
Line 57:         Counts = PgCount

Source File: C:\Inetpub\vhosts\geniuslighting.com\httpdocs\App_Code\DBop.vb    Line: 55

Stack Trace:


[InvalidOperationException: ExecuteScalar requires an open and available Connection. The connection's current state is closed.]
   System.Data.OleDb.OleDbConnection.CheckStateOpen(String method) +1566815
   System.Data.OleDb.OleDbCommand.ValidateConnection(String method) +29
   System.Data.OleDb.OleDbCommand.ValidateConnectionAndTransaction(String method) +25
   System.Data.OleDb.OleDbCommand.ExecuteReaderInternal(CommandBehavior behavior, String method) +70
   System.Data.OleDb.OleDbCommand.ExecuteScalar() +145
   DBop.Counts(String Sql) in C:\Inetpub\vhosts\geniuslighting.com\httpdocs\App_Code\DBop.vb:55
   DBop.getTotalRep(AspNetPager anp, Repeater rep, String sqlTotal, String sqlBind) in C:\Inetpub\vhosts\geniuslighting.com\httpdocs\App_Code\DBop.vb:292
   products_index.repbind() in C:\Inetpub\vhosts\geniuslighting.com\httpdocs\products\index.aspx.vb:8
   products_index.Page_Load(Object sender, EventArgs e) in C:\Inetpub\vhosts\geniuslighting.com\httpdocs\products\index.aspx.vb:13
   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.4676.0