Results 1 to 2 of 2

Thread: Imports

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Sep 2004
    Location
    Kolkata, India
    Posts
    290

    Imports

    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

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Imports

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width