Connectivity Guide > Connectivity Guide > Understanding .NET Data Provider Connectivity > ExecuteNonQuery Method--Modify and Update Database
Was this helpful?
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();
}
Last modified date: 01/30/2023