Imports System.Data or Imports System.Data.SqlClient?

Discussion in 'ASP .Net' started by Albert, Jul 9, 2008.

  1. Albert

    Albert Guest

    Hi,

    when do i need this: Imports System.Data
    and when this: Imports System.Data.SqlClient?

    More specifically, when i want to perform a select or update of a table
    using:
    connection = New SqlConnection(connectionstr)
    comd = New SqlCommand()

    do i need both?
    Thanks
    Albert
     
    Albert, Jul 9, 2008
    #1
    1. Advertising

  2. Imports statement supplies references to all definitions in the namespace.
    So, if you use any classes from the System.Data namespaces, use Imports
    System.Data. In your example both SqlConnection and SqlCommand belong to the
    System.Data.SqlClient namespace, so use Imports System.Data.SqlClient.

    In fact, you can always use full names like
    connection = New System.Data.SqlClient.SqlConnection(connectionstr)

    In this case you don't need to use Imports statement.


    --
    Eliyahu Goldin,
    Software Developer
    Microsoft MVP [ASP.NET]
    http://msmvps.com/blogs/egoldin
    http://usableasp.net


    "Albert" <> wrote in message
    news:%...
    > Hi,
    >
    > when do i need this: Imports System.Data
    > and when this: Imports System.Data.SqlClient?
    >
    > More specifically, when i want to perform a select or update of a table
    > using:
    > connection = New SqlConnection(connectionstr)
    > comd = New SqlCommand()
    >
    > do i need both?
    > Thanks
    > Albert
    >
     
    Eliyahu Goldin, Jul 9, 2008
    #2
    1. Advertising

  3. Albert

    Albert Guest

    Thanks,

    can you give me an example where i need imports.system.data, or with other
    words, what are the classes from System.Data namespaces?
    Thanks


    "Eliyahu Goldin" <> schreef in
    bericht news:%...
    > Imports statement supplies references to all definitions in the namespace.
    > So, if you use any classes from the System.Data namespaces, use Imports
    > System.Data. In your example both SqlConnection and SqlCommand belong to
    > the System.Data.SqlClient namespace, so use Imports System.Data.SqlClient.
    >
    > In fact, you can always use full names like
    > connection = New System.Data.SqlClient.SqlConnection(connectionstr)
    >
    > In this case you don't need to use Imports statement.
    >
    >
    > --
    > Eliyahu Goldin,
    > Software Developer
    > Microsoft MVP [ASP.NET]
    > http://msmvps.com/blogs/egoldin
    > http://usableasp.net
    >
    >
    > "Albert" <> wrote in message
    > news:%...
    >> Hi,
    >>
    >> when do i need this: Imports System.Data
    >> and when this: Imports System.Data.SqlClient?
    >>
    >> More specifically, when i want to perform a select or update of a table
    >> using:
    >> connection = New SqlConnection(connectionstr)
    >> comd = New SqlCommand()
    >>
    >> do i need both?
    >> Thanks
    >> Albert
    >>

    >
    >
     
    Albert, Jul 9, 2008
    #3
  4. Sure.

    http://msdn.microsoft.com/en-us/library/system.data.aspx

    --
    Eliyahu Goldin,
    Software Developer
    Microsoft MVP [ASP.NET]
    http://msmvps.com/blogs/egoldin
    http://usableasp.net


    "Albert" <> wrote in message
    news:%...
    > Thanks,
    >
    > can you give me an example where i need imports.system.data, or with other
    > words, what are the classes from System.Data namespaces?
    > Thanks
    >
    >
    > "Eliyahu Goldin" <> schreef in
    > bericht news:%...
    >> Imports statement supplies references to all definitions in the
    >> namespace. So, if you use any classes from the System.Data namespaces,
    >> use Imports System.Data. In your example both SqlConnection and
    >> SqlCommand belong to the System.Data.SqlClient namespace, so use Imports
    >> System.Data.SqlClient.
    >>
    >> In fact, you can always use full names like
    >> connection = New System.Data.SqlClient.SqlConnection(connectionstr)
    >>
    >> In this case you don't need to use Imports statement.
    >>
    >>
    >> --
    >> Eliyahu Goldin,
    >> Software Developer
    >> Microsoft MVP [ASP.NET]
    >> http://msmvps.com/blogs/egoldin
    >> http://usableasp.net
    >>
    >>
    >> "Albert" <> wrote in message
    >> news:%...
    >>> Hi,
    >>>
    >>> when do i need this: Imports System.Data
    >>> and when this: Imports System.Data.SqlClient?
    >>>
    >>> More specifically, when i want to perform a select or update of a table
    >>> using:
    >>> connection = New SqlConnection(connectionstr)
    >>> comd = New SqlCommand()
    >>>
    >>> do i need both?
    >>> Thanks
    >>> Albert
    >>>

    >>
    >>

    >
    >
     
    Eliyahu Goldin, Jul 10, 2008
    #4
  5. Albert

    Albert Guest

    Thanks

    "Eliyahu Goldin" <> schreef in
    bericht news:...
    > Sure.
    >
    > http://msdn.microsoft.com/en-us/library/system.data.aspx
    >
    > --
    > Eliyahu Goldin,
    > Software Developer
    > Microsoft MVP [ASP.NET]
    > http://msmvps.com/blogs/egoldin
    > http://usableasp.net
    >
    >
    > "Albert" <> wrote in message
    > news:%...
    >> Thanks,
    >>
    >> can you give me an example where i need imports.system.data, or with
    >> other words, what are the classes from System.Data namespaces?
    >> Thanks
    >>
    >>
    >> "Eliyahu Goldin" <> schreef in
    >> bericht news:%...
    >>> Imports statement supplies references to all definitions in the
    >>> namespace. So, if you use any classes from the System.Data namespaces,
    >>> use Imports System.Data. In your example both SqlConnection and
    >>> SqlCommand belong to the System.Data.SqlClient namespace, so use Imports
    >>> System.Data.SqlClient.
    >>>
    >>> In fact, you can always use full names like
    >>> connection = New System.Data.SqlClient.SqlConnection(connectionstr)
    >>>
    >>> In this case you don't need to use Imports statement.
    >>>
    >>>
    >>> --
    >>> Eliyahu Goldin,
    >>> Software Developer
    >>> Microsoft MVP [ASP.NET]
    >>> http://msmvps.com/blogs/egoldin
    >>> http://usableasp.net
    >>>
    >>>
    >>> "Albert" <> wrote in message
    >>> news:%...
    >>>> Hi,
    >>>>
    >>>> when do i need this: Imports System.Data
    >>>> and when this: Imports System.Data.SqlClient?
    >>>>
    >>>> More specifically, when i want to perform a select or update of a table
    >>>> using:
    >>>> connection = New SqlConnection(connectionstr)
    >>>> comd = New SqlCommand()
    >>>>
    >>>> do i need both?
    >>>> Thanks
    >>>> Albert
    >>>>
    >>>
    >>>

    >>
    >>

    >
    >
     
    Albert, Jul 10, 2008
    #5
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. William F. Robertson, Jr.

    Re: vbc cant find system.data.sqlClient.sqlConnection

    William F. Robertson, Jr., Jul 28, 2003, in forum: ASP .Net
    Replies:
    0
    Views:
    677
    William F. Robertson, Jr.
    Jul 28, 2003
  2. Bob of the West
    Replies:
    1
    Views:
    2,962
    William F. Robertson, Jr.
    May 17, 2004
  3. =?Utf-8?B?S2FseWFu?=
    Replies:
    2
    Views:
    1,426
    =?Utf-8?B?S2FseWFu?=
    Jun 18, 2004
  4. TN Bella
    Replies:
    2
    Views:
    2,324
    TN Bella
    Jun 20, 2004
  5. egsdar
    Replies:
    0
    Views:
    1,601
    egsdar
    Dec 13, 2008
Loading...

Share This Page