Databases Reference
In-Depth Information
// Close the DataReader
dataReader.Close();
}
finally {
dataReader.Close();
cmd.Dispose();
}
Performance Tip
Because of the significant amount of disk I/O on the database server
required to commit every operation and the extra network round trips
that occur between the data provider and the database server, it's a
good idea to turn off auto-commit mode in your application and use
manual commits instead. Using manual commits allows your application
to control when database work is committed, which provides dramati-
cally better performance. Auto-commit mode is automatically turned off
when a transaction is explicitly requested.
For example, let's look at the following code. It's identical to the previous
code except that it turns off auto-commit mode by starting a transaction and
uses manual commits.
// For conciseness, this code omits error checking
// Start the transaction. This turns auto-commit off.
transaction = conn.BeginTransaction();
// Allocate a Command object
cmd = conn.CreateCommand();
cmd.Transaction = transaction;
// Bind parameters
cmd.Parameters.Add("id", DB2DbType.Integer);
Search WWH ::




Custom Search