Hi
I am using the vb.net and sql server 2005
Is it neccessary to Imports both
Imports System.Data
Imports System.Data.SqlClient
or - only
Imports System.Data.SqlClient
thanks
Printable View
Hi
I am using the vb.net and sql server 2005
Is it neccessary to Imports both
Imports System.Data
Imports System.Data.SqlClient
or - only
Imports System.Data.SqlClient
thanks
It's not necessary to import anything. Do you know what an import does? It allows you to refer to members of the name you import without qualifying them. If you import System.Data.SqlClient then you can just refer to an SqlConnection, while if you don't you have to qualify it, e.g. System.Data.SqlClient.SqlConnection. Now, having said that, System.Data is already imported by default. That means that you can refer to any members of System.Data unqualified, e.g. SqlClient.SqlConnection.
The moral of the story is that you don't have to import anything but you would normally import any namespaces whose members you will refer to regularly. If you don't intend to refer to a member of a namespace then you definitely wouldn't import it.