Before anything else, you need to decide what data provider you'll use in your applications. Once you've decided, you need to include the namespace in your applications so the namespace objects are available to you. You include a namespace by adding an Imports directive, followed by the namespace, to your project. The following lines import the System.Data, System.Data.Common, System.Data.SqlClient, and System.Data.OleDb namespaces of ADO.NET:
Imports System.Data Imports System.Data.Common Imports System.Data.SqlClient Imports System.Data.OleDb
In later chapters, we discuss other data providers—such as Odbc and Oracle— and their related namespaces.
You can also access a namespace's objects by specifying the full namespace when you declare the objects. For example, the following code accesses the SqlConnection class of the System.Data.SqlClient namespace (in this case, you don't need to use the Imports statement):
Dim conn As SqlConnection = New SqlClient.SqlConnection()
The previous code is equivalent to the following code:
Imports System.Data.SqlClient Dim conn As SqlConnection = New SqlConnection()