The main aim of this blog is to give a better coding experience to those programmers who are good in VB6 but know nothing about VB.Net 2005. This blog will provide hard coding experience in VB.Net 2005 and Dot Net Framework 2.0.
ADO.Net opens up a whole new world of data access, giving you the power to control the changes you make to your data. Each ADO.Net component has its own specialty, unlike the Recordset, which is a jack-of-all-trades. In ADO.NET, you always know what to expect from your data access objects, and this lets you streamline your code with specific functionality and greater control.
To comfortably use the ADO.NET objects in an application, you should use the IMPORTS statement. By doing so, you can declare ADO.NET variables without having to fully qualify them. You could type the following IMPORTS statement at the top of your solution:
Imports System.Data.SqlClient
The above statement is called Namespace. So, what is a Namespace and what is the importance of them?
A Namespace is a collection of different classes which are built in to .Net. You need to import theses namespaces to work with any .Net language. All the functionality of .Net is within these namespaces.
System.Data: Include classes that make up ADO.Net and allow building data-handling components.
So, before proceeding with the coding we have to use this statement:
Imports System.Data.SqlClient
After this, you can work with the SqlClient ADO.NET objects without having to fully qualify the class names.
The five core objects form the foundation of the ADO.Net object model is: Connection, Command, DataReader, DataSet and DataAdapter. The Connection,Command,DataReader and DataAdapter belong to the .NET data provider, whereas the DataSet is part of the disconnected data storage mechanism.
Four core objects belong to .NET data providers, within the ADO.NET managed provider architecture is: the Connection, Command, DataReader and DataAdapter objects.
The Connection
object is the simplest one, because it establishes a connection to the database.
The Command object exposes a Parameters collection, which contains information about the parameters of the command to be executed.
The DataReader object provides fast access to read-only, forward-only data, which is identical to read-only, forward-only ADO Recordset in VB6.0.
The DataAdapter object contains Command objects that enable you to map specific actions to your data source. The DataAdapter is a mechanism for bridging the managed providers with the disconnected DataSets.
The DataSet object is not part of the ADO.NET managed provider architecture. The DataSet exposes a collection of DataTables, which in turn contain both DataColumn and DataRow collections. The DataTables collection can be used in conjunction with the DataRelation collection to create relational data structures.