473,382 Members | 1,615 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,382 software developers and data experts.

Wierdness with "Imports" statement

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 SqlConnection = New SqlConnection()
Public AdapterObjG As SqlDataAdapter = New SqlDataAdapter()

...
-----

I get the following errors:
Type 'SqlConnection' is not defined.
Type 'SqlDataAdapter' is not defined.

The wierd part is that I get the squiggly "you did something wrong"
underlines after "New" but not after "As". If you don't have Visual
Studio .NET, the squiggly underlines shows where the errors are (like
the spellchecker in MS Word).

Even more strange: If I put the following code in my web.config file, I
get no errors at all.

-----
<add namespace="System.Data.SqlClient" />
-----

Any idea what's going on here? Why is Import not importing?

Thanks,

-Dan

Dec 16 '05 #1
2 1297
KJ
OK, here's a dumb question: did you add a project reference to
System.Data?

Dec 16 '05 #2
Yes. I have that in my web.config file. I also just tried adding an
"Imports System.Data" statement to the code module, but I still get the
same error.

Another thing I just tried:

-----
Imports System.Data.SqlClient

Partial Class PageHeader

Inherits System.Web.UI.UserControl

Public ConnectionObjG As SqlConnection = New
SqlClient.SqlConnection()
Public AdapterObjG As SqlDataAdapter = New
SqlClient.SqlDataAdapter()
....
-----

No errors. Why?

Isn't it strange that the only the second reference in each case needs
the "SqlClient" prefix?

Thx,

-Dan

Dec 16 '05 #3

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

Similar topics

8
by: Dgates | last post by:
Has anyone typed up an index for the O'Reilly book "C# and VB.NET Conversion?" I'm just learning C#, and often using this little book to see which VB.NET terms translate directly to some term in...
2
by: darrel | last post by:
I've built a control. At the top of my control, I have this: Imports Microsoft.VisualBasic Then, later, I call a function like this: DateTime.Now.Year.ToString() This works fine on my...
1
by: A. Nonymous | last post by:
If I make my own Namespace do I have to compile it to a DLL before I can use the line: Imports MyNamespace anywhere? TIA
3
by: KRC | last post by:
I am using an external object called WebZinc to help parse web pages in VB.net. I am trying to use a particular method following the example in the help reference but am unable to get VB.net to...
3
by: Chris | last post by:
Hi, 1) In file test.aspx, i put: <%@ Page Language="VB" AutoEventWireup="false" CodeFile="test.aspx.vb" Inherits="test" %> <%@ import namespace="System.Data"%> <%@ import...
7
by: pcnerd | last post by:
In Java I can use, for example, " Imports java.util.* ". Can I use, for example, " Imports System.* " instead of several different "Imports" statements? Thank you. David
1
by: Terry Olsen | last post by:
I have written a class library that I want to reference from a windows app. The filename is UPSTrackTool.dll. The Class name is UPSTrackTool. When I reference it from my windows app, I put the...
1
by: Alexander Eisenhuth | last post by:
Hi, PyLint says that "Relative imports" ... are worth to be warned . And I ask myself why? ----------------- Example directory structure --------- Sound/ Top-level package...
5
by: kimiraikkonen | last post by:
Hello, I want to ask about "imports" statement. Some projects must be inserted with "imports xxxx" statements before beginning coding. But how do i know when to use or do i have to use "imports"...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.