12. Understanding .NET Data Provider Connectivity : ExecuteNonQuery Method--Modify and Update Database
 
Share this page                  
ExecuteNonQuery Method--Modify and Update Database
Using the .NET Data Provider, you can use the IngresCommand's ExecuteNonQuery method to process SQL statements that modify data but do not return rows, such as INSERT, UPDATE, DELETE, and other non-resultset commands such as CREATE TABLE.
Although rows are not returned by the ExecuteNonQuery method, input and output parameters and return values can be passed and returned using the Parameters property of the IngresCommand object.
The following code example executes an UPDATE statement to update a record in a database using ExecuteNonQuery:
static void DemoUpdate(string connstring)
{
    IngresConnection conn = new IngresConnection(connstring);

    conn.Open();
    IngresCommand cmd = new IngresCommand(
        "update demo_personnel set name = 'Howard Lane' "+
        " where number = 200", conn);

    int numberOfRecordsAffected = cmd.ExecuteNonQuery();

    Console.WriteLine(numberOfRecordsAffected.ToString() +
        " records updated.");

    conn.Close();
}