Creating the Components

The first thing to do is add the data components to form. Add an SqlConnection, an SqlDataAdapter, and a DataSet. Cancel out of the wizard for the SqlDataAdapter. When the DataSet configuration wizard appears, select untyped DataSet and click OK. Name the SqlConnection mConnection, the SqlDataAdapter mAdapter, and the DataSet mDataset. Close the Designer window and open the Code window.

Data Navigation

Now it’s time to start writing code. The first bit of functionality to add is the ability to connect to a database. We will use our Connection object for this. First create a property to expose the Connection object to the world. This will have an interesting effect we will look at later on:

 Public Property Connection() ...

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.