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

Discussion in 'ASP .Net' started by Lauchlan M, May 21, 2004.

  1. Lauchlan M

    Lauchlan M Guest

    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

    >>
     
    Lauchlan M, May 21, 2004
    #1
    1. Advertising

  2. Lauchlan M

    Lauchlan M Guest

    Sorted/fixed.

    Thx

    Lauchlan M
     
    Lauchlan M, May 21, 2004
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Lauchlan M

    "Connection must valid and open" error?

    Lauchlan M, May 20, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    1,739
    Lauchlan M
    May 21, 2004
  2. Bazza Formez
    Replies:
    4
    Views:
    423
    Vanni Tomezzoli
    Dec 9, 2004
  3. wxl
    Replies:
    2
    Views:
    2,744
  4. IK

    How to find grid's row that matches row in dataset

    IK, Sep 15, 2003, in forum: ASP .Net Datagrid Control
    Replies:
    0
    Views:
    205
  5. D
    Replies:
    0
    Views:
    257
Loading...

Share This Page