I have a form in which I have multiple records that need to be either inserted or updated in the database. I am using a stored procedure to save the
information. Not using the Data Application Block I would open a connection once, save all of the records and then close the connection after
inserting the new records, in order to not create multiple database connections.
If I use the Data Application Block how do I open a connection and then close it manually? Or does the Data Application Block do this automatically?
I want to be able to insert update new records efficiently.
DAAB manages the opening and closing of connections most of the time. When inserting records, you need not open and close connection manually.
Database db = DatabaseFactory.CreateDatabase();
DbCommand command = db.GetStoredProcCommand(spname);
There are times though that a connection is left open like in the case of returning a datareader. In this case make sure to close or dispose the datareader in order to close the connection.
Global Technology & Solutions