Deleting row from asp.net grid - "Connection must valid and open" error?

L

Lauchlan M

I get the following error. Apart from the fact that it does not make any
grammatical sense, what would be likely to be causing it?

I have a command component 'nxCmdDeleteErrorLogItem' with the following SQL:

Delete from ErrorLog where LogID = ?

LogID is a parameter corresponding to a DB field LogID which is an autoinc
field (the parameter is set at Int32).

I know the connection is ok (it works in the rest of the code, the only
problem occurs when I try to do this delete).

Thanks,

Lauchlan M

<<

Server Error in '/MyWebInterface_NexusDB' Application.
----------------------------------------------------------------------------
----

Connection must valid and open
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: Connection must valid
and open

Source Error:

Line 351: nxCmdDeleteErrorLogItem.Parameters["LogID"].Value =
dGridErrorLog.DataKeys[e.Item.ItemIndex];
Line 352: nxConnection.Open();
Line 353: nxCmdDeleteErrorLogItem.ExecuteNonQuery(); // error occurs here
Line 354: nxConnection.Close();

Source File:
e:\inetpub\wwwroot\Mywebinterface_nexusdb\admin\viewerrorlog.aspx.cs
Line: 353

Stack Trace:

[InvalidOperationException: Connection must valid and open]
NexusDB.ADOProvider.NxCommand.ExecuteNonQuery()

MyWebInterface_NexusDB.Admin.ViewErrorLog.dGridErrorLog_DeleteCommand(Object
source, DataGridCommandEventArgs e) in
e:\inetpub\wwwroot\Mywebinterface_nexusdb\admin\viewerrorlog.aspx.cs:353

System.Web.UI.WebControls.DataGrid.OnDeleteCommand(DataGridCommandEventArgs
e) +110
System.Web.UI.WebControls.DataGrid.OnBubbleEvent(Object source, EventArgs
e) +589
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +26
System.Web.UI.WebControls.DataGridItem.OnBubbleEvent(Object source,
EventArgs e) +106
System.Web.UI.Control.RaiseBubbleEvent(Object source, EventArgs args) +26
System.Web.UI.WebControls.LinkButton.OnCommand(CommandEventArgs e) +121

System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.Rai
sePostBackEvent(String eventArgument) +115
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +138
System.Web.UI.Page.ProcessRequestMain() +1277
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,816
Latest member
nipsseyhussle

Latest Threads

Top