Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Imports System.Data or Imports System.Data.SqlClient?

Reply
Thread Tools

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

 
 
Albert
Guest
Posts: n/a
 
      07-09-2008
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


 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      07-09-2008
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" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
 
 
 
Albert
Guest
Posts: n/a
 
      07-09-2008
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" <(E-Mail Removed)> schreef in
bericht news:%(E-Mail Removed)...
> 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" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> 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
>>

>
>



 
Reply With Quote
 
Eliyahu Goldin
Guest
Posts: n/a
 
      07-10-2008
Sure.

http://msdn.microsoft.com/en-us/libr...stem.data.aspx

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


"Albert" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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" <(E-Mail Removed)> schreef in
> bericht news:%(E-Mail Removed)...
>> 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" <(E-Mail Removed)> wrote in message
>> news:%(E-Mail Removed)...
>>> 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
>>>

>>
>>

>
>



 
Reply With Quote
 
Albert
Guest
Posts: n/a
 
      07-10-2008
Thanks

"Eliyahu Goldin" <(E-Mail Removed)> schreef in
bericht news:(E-Mail Removed)...
> Sure.
>
> http://msdn.microsoft.com/en-us/libr...stem.data.aspx
>
> --
> Eliyahu Goldin,
> Software Developer
> Microsoft MVP [ASP.NET]
> http://msmvps.com/blogs/egoldin
> http://usableasp.net
>
>
> "Albert" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
>> 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" <(E-Mail Removed)> schreef in
>> bericht news:%(E-Mail Removed)...
>>> 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" <(E-Mail Removed)> wrote in message
>>> news:%(E-Mail Removed)...
>>>> 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
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamic imports + relative imports in Python 3 zildjohn01 Python 0 02-22-2011 05:24 PM
Bit lost (inherits/imports) for secure login... Rob Meade ASP .Net 0 01-28-2004 01:24 PM
Re: Imports Jim Heavey ASP .Net 1 10-17-2003 06:00 PM
REFERENCE VS IMPORTS Bite My Bubbles ASP .Net 0 08-25-2003 09:00 PM
Imports 'System.DirectoryServices' cannot be found. Edward ASP .Net 1 07-08-2003 12:45 AM



Advertisments