First things first, we will need a database. Attached to this article is an Access database that I prepared earlier and will form the basis for this guide. If you download this database now, we will then move along to creating the user interface.
I have based this tutorial on code that is compatible with the .NET Framework 1.1 so you can use either VS 2003 or 2005 when following along. Assuming that you now have your development environment loaded, the first thing we will do is to create a project. A Windows Application project type is required for this demonstration and the code in this tutorial is written in VB.NET.
As the first part of this tutorial is solely concentrating on how to connect to a database and retrieve simple information, the user interface does not need to be too complex. So the ideal control to drop onto our form at this point will be the DataGrid (Note, if you are using VS 2005 you can add the DataGrid component to your Toolbox by right clicking on the Toolbox and selecting "Choose Items...". Alternatively, use the DataGridView component). I have named my DataGrid "dgContacts" and have also added a button to the bottom of the form in order to close the application, aptly named "btnClose". Your user interface should then resemble something similar to the following screen shot:
The Address Book User Interface
The next part of this tutorial will look at connecting to the database that you downloaded previously and populating the DataGrid with the contents of the "Contacts" table from said database. Before moving on however, I recommend that you copy the database that you have downloaded to your projects bin\Debug folder. This will make connecting to the database easier as we will know that the location of the database will be in the same place as the executable for this program and thus we can use the Application.StartupPath method to grab this location.