Initialization Code

Before we continue, let’s finish the initialization code. Go back to the constructor. After the code we added to wire the events, let’s add this code:

mSQLBuilder = New SqlClient.SqlCommandBuilder(mAdapter) 
mAdapter.SelectCommand = New SqlClient.SqlCommand("", mConnection) 
mAdapter.InsertCommand = New SqlClient.SqlCommand("", mConnection) 
mAdapter.DeleteCommand = New SqlClient.SqlCommand("", mConnection) 
mAdapter.UpdateCommand = New SqlClient.SqlCommand("", mConnection) 

mDataSet.Tables.Add() 

These initializers just precreate the objects mentioned so they show up in the Property window correctly. Before the region add the following declarations. The region statement is shown for a point of reference:

 Private mSQLBuilder ...

Get ADO.NET Programming in Visual Basic™ .NET now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.