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


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).


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 =
Line 352: nxConnection.Open();
Line 353: nxCmdDeleteErrorLogItem.ExecuteNonQuery(); // error occurs here
Line 354: nxConnection.Close();

Source File:
Line: 353

Stack Trace:

[InvalidOperationException: Connection must valid and open]

source, DataGridCommandEventArgs e) in

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

sePostBackEvent(String eventArgument) +115
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