Issuing a Command that Deletes a Row

Issue a command that deletes a row.

  1. Declare and initialize an AseConnection object:

    For C#:

    AseConnection conn = new AseConnection(c_connStr);

    For Visual Basic .NET:

    Dim conn As New AseConnection(c_connStr)
  2. Open the connection:

    For C#:

    conn.Open();

    For Visual Basic .NET:

    conn.Open()
  3. Create an AseCommand object to define and execute a Delete statement:

    For C#:

    AseCommand updateCmd = new AseCommand
       "DELETE FROM publishers " +
       " WHERE (pub_id > '9900')",
       conn );

    For Visual Basic .NET:

    Dim updateCmd As New AseCommand(_
    "DELETE FROM publishers " + _
    "WHERE (pub_id > '9900')", _
    conn )
  4. Call the ExecuteNonQuery method to apply the changes to the database:

    For C#:

    int recordsAffected = deleteCmd.ExecuteNonQuery();

    For Visual Basic .NET:

    Dim recordsAffected As Integer =
       updateCmd.ExecuteNonQuery()
  5. Close the AseConnection object:

    For C#:

    conn.Close();

    For Visual Basic .NET:

    dr.Close()
    conn.Close()