Working with ADO.NET
(Page 1 of 4 )
This article, part one of a series, discusses the workings of ADO.NET. With the help of an example application, you will learn to manipulate data in a Microsoft Access database, including how to insert, search, and navigate records.
ADO.NET is an exciting technology provided by the .NET Framework. Prior to ADO.NET, we used ADO (Active Data Objects) with Visual Studio 6. Even though it performs the required task, developers needed to write long lines of code. With ADO.NET, data access is simpler than ever. The .NET Framework ships with the required namespaces for working with ADO.NET. It also comes with two different sets of providers for OLEDB (MS Access) and SQL Server databases. The syntaxes of both these providers are the same except a few changes to the controls. Once you master the working of any one of the providers, it is easy to port the code to other databases.
In this article, you will learn about the workings of ADO.NET with the help of a Windows Forms project titled Customer Database Application. The application uses a Microsoft Access database to manipulate data and Visual Basic .NET as the programming language. With the help of this application, you can perform the following tasks:
- Inserting records
- Navigating records (previous, next, first and last records)
- Searching records from the database
User Interface
The sample application used for this article consists of two forms. The first form is the core of our application, which will prompt you to enter Name and E-mail. You can add additional fields depending upon your requirements. It also includes the required buttons which will perform the required actions such as addition and record navigation (see figure 1).

The second form of our application consists of a ComboBox and a TextBox control. It will be populated with all of the names which are in the database. It will perform a search on the database, and the text box will display the relevant e-mail address, which matches the corresponding name in the database (see figure 2).

You can edit and delete the data using the second form. This can be done only after searching for the appropriate record using the search functionality. I will discuss editing and deleting data in the next part of this article.
I have developed the sample application using Visual Studio .NET 2003. Hence, I have used the built-in controls for connecting to the database on the first form, which is used for data entry and the traditional coding approach for the search functionality. This will help you to learn about the usage of both techniques for connecting to a database.
Launch Visual Studio .NET 2003 and create a new Windows Forms project. Design a user interface as shown in the first figure above and supply the required properties as shown in the table given below. You have to connect the form to the required database. For this purpose, you can use the built-in data controls which ship with the .NET Framework. Follow the procedure as shown in the next section to properly connect to the database.
Next: Connecting to the database >>
More .NET Articles
More By Anand Narayanaswamy