473,406 Members | 2,343 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

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

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
Jul 9 '08 #1
4 5172
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" <wx***@sss.sdwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
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

Jul 9 '08 #2
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" <RE**************************@mMvVpPsS.orgschree f in
bericht news:%2****************@TK2MSFTNGP02.phx.gbl...
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" <wx***@sss.sdwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>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


Jul 9 '08 #3
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" <wx***@sss.sdwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
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" <RE**************************@mMvVpPsS.orgschree f in
bericht news:%2****************@TK2MSFTNGP02.phx.gbl...
>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" <wx***@sss.sdwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl...
>>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



Jul 10 '08 #4
Thanks

"Eliyahu Goldin" <RE**************************@mMvVpPsS.orgschree f in
bericht news:Ok**************@TK2MSFTNGP06.phx.gbl...
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" <wx***@sss.sdwrote in message
news:%2****************@TK2MSFTNGP06.phx.gbl...
>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" <RE**************************@mMvVpPsS.orgschree f in
bericht news:%2****************@TK2MSFTNGP02.phx.gbl...
>>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" <wx***@sss.sdwrote in message
news:%2****************@TK2MSFTNGP03.phx.gbl.. .
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



Jul 10 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: David Lozzi | last post by:
I'm trying to do this: <%@ Page Language="VB" %> <script runat="server"> Imports System.Data Imports System.Data.SqlClient But i get this error on line 4:
2
by: Chris Langston | last post by:
I have a Web Server running IIS 5 or 6 on Windows 2K and Windows 2003 Server that is experiencing strange shutdown problems. We are using ASP.NET v1.1 and our application is written in VB.NET ...
3
by: | last post by:
I'm picking up an 'IMPORTS' error for a simple database insert based on two input entry boxes in my form? It says an 'Imports' statement must preceede any declarations....... is this perahps the...
5
by: Shapper | last post by:
Hello, I am working in a web site where all the code is placed in aspx.vb files. After a while I realized that many functions included in my aspx.vb files where common to all pages. I...
2
by: danthman | last post by:
Can someone tell me why the following VB.NET code doesn't work? ----- Imports System.Data.SqlClient Partial Class PageHeader Inherits System.Web.UI.UserControl Public ConnectionObjG As...
0
by: chilli | last post by:
Imports System.Data.SqlClient Imports CrystalDecisions.Shared Imports CrystalDecisions.CrystalReports imports system.data.sqlclient imports system.data.oledb
4
by: BillE | last post by:
Does a subclass have to import namespaces which were already imported by the superclass? I have a base class which imports the System.Data.SQLClient namespace to use the dataset member. When...
3
by: weird0 | last post by:
This is the exception that I get when i create a webserivce obj and call. The error comes on the webmethod call, when it opens a connection to the db. How do I fix it? What is the solution to...
1
by: Pedro Dinis | last post by:
i have this class library that connects to the database(see appconfig below) compiling 0 errors but when its running i amhaving this error An unhandled exception of type...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.