473,406 Members | 2,769 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.

Errors when Compiling a Class File

Hi,

I'm creating a Class file that contains a function that queries the
database. I receive alot of connection type errors when I try to compile
and I'm not sure what I'm doing wrong.

This is my dataClass.vb file:
Imports System
Imports Microsoft.VisualBasic
Imports System.Web

Namespace Data

Public Class dataClass

Public Shared Function GetPage(ByVal pageNumber As Integer) As
IDataReader

Dim strConnection As String
strConnection = ConfigurationSettings.AppSettings
("ConnectionString")

Dim dbConnection As New SqlConnection(strConnection)

Dim queryString As String = "SELECT [tblPage].* From tblPage"

Dim dbCommand As New SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

Dim dbParam_pageNumber As New SqlParameter
dbParam_pageNumber.ParameterName = "@PageNumber"
dbParam_pageNumber.Value = pageNumber
dbParam_pageNumber.DbType = DbType.Int32
dbCommand.Parameters.Add(dbParam_pageNumber)

dbConnection.Open
Dim dataReader As IDataReader = dbCommand.ExecuteReader
(CommandBehavior.CloseConnection)

Return dataReader

End Function
End Class
End Namespace
These are the errors I receive:

C:\Inetpub\wwwroot\web\dataClass.vb(12) : error BC30002: Type 'IDataReader'
is n
ot defined.

Public Shared Function GetPage(ByVal pageNumber As Integer) As
IDataRead
er

~~~~~~~~~
~~
C:\Inetpub\wwwroot\web\dataClass.vb(15) : error BC30451: Name
'ConfigurationSett
ings' is not declared.

strConnection = ConfigurationSettings.AppSettings
("ConnectionString"
)
~~~~~~~~~~~~~~~~~~~~~

C:\Inetpub\wwwroot\web\dataClass.vb(17) : error BC30002: Type
'SqlConnection' is
not defined.

Dim dbConnection As New SqlConnection(strConnection)
~~~~~~~~~~~~~
C:\Inetpub\wwwroot\web\dataClass.vb(21) : error BC30002: Type 'SqlCommand'
is no
t defined.

Dim dbCommand As New SqlCommand
~~~~~~~~~~
C:\Inetpub\wwwroot\web\dataClass.vb(25) : error BC30002: Type
'SqlParameter' is
not defined.

Dim dbParam_pageNumber As New SqlParameter
~~~~~~~~~~~~
C:\Inetpub\wwwroot\web\dataClass.vb(28) : error BC30451: Name 'DbType' is
not de
clared.

dbParam_pageNumber.DbType = DbType.Int32
~~~~~~
C:\Inetpub\wwwroot\web\dataClass.vb(32) : error BC30002: Type 'IDataReader'
is n
ot defined.

Dim dataReader As IDataReader = dbCommand.ExecuteReader
(CommandBehav
ior.CloseConnection)
~~~~~~~~~~~

I'm using the following Batch file to compile:

Set PATH=%SystemRoot%\Microsoft.NET\Framework\v1.1.432 2
cd c:\inetpub\wwwroot\web
vbc dataClass.vb /t:library /r:System.Web.dll /out:bin\dataClass.dll
pause
Thanks so much for any help.

--
Message posted via http://www.dotnetmonster.com
Nov 19 '05 #1
3 1477
You need to include the following imports:

Imports System.Configuration
Imports System.Data.SqlClient
as some of the classes you are using belong to the above namespaces.

--
Manohar Kamath
Editor, .netWire
www.dotnetwire.com
"Joe via DotNetMonster.com" <fo***@DotNetMonster.com> wrote in message
news:34******************************@DotNetMonste r.com...
Hi,

I'm creating a Class file that contains a function that queries the
database. I receive alot of connection type errors when I try to compile
and I'm not sure what I'm doing wrong.

This is my dataClass.vb file:
Imports System
Imports Microsoft.VisualBasic
Imports System.Web

Namespace Data

Public Class dataClass

Public Shared Function GetPage(ByVal pageNumber As Integer) As
IDataReader

Dim strConnection As String
strConnection = ConfigurationSettings.AppSettings
("ConnectionString")

Dim dbConnection As New SqlConnection(strConnection)

Dim queryString As String = "SELECT [tblPage].* From tblPage"

Dim dbCommand As New SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

Dim dbParam_pageNumber As New SqlParameter
dbParam_pageNumber.ParameterName = "@PageNumber"
dbParam_pageNumber.Value = pageNumber
dbParam_pageNumber.DbType = DbType.Int32
dbCommand.Parameters.Add(dbParam_pageNumber)

dbConnection.Open
Dim dataReader As IDataReader = dbCommand.ExecuteReader
(CommandBehavior.CloseConnection)

Return dataReader

End Function
End Class
End Namespace
These are the errors I receive:

C:\Inetpub\wwwroot\web\dataClass.vb(12) : error BC30002: Type 'IDataReader' is n
ot defined.

Public Shared Function GetPage(ByVal pageNumber As Integer) As
IDataRead
er

~~~~~~~~~
~~
C:\Inetpub\wwwroot\web\dataClass.vb(15) : error BC30451: Name
'ConfigurationSett
ings' is not declared.

strConnection = ConfigurationSettings.AppSettings
("ConnectionString"
)
~~~~~~~~~~~~~~~~~~~~~

C:\Inetpub\wwwroot\web\dataClass.vb(17) : error BC30002: Type
'SqlConnection' is
not defined.

Dim dbConnection As New SqlConnection(strConnection)
~~~~~~~~~~~~~
C:\Inetpub\wwwroot\web\dataClass.vb(21) : error BC30002: Type 'SqlCommand'
is no
t defined.

Dim dbCommand As New SqlCommand
~~~~~~~~~~
C:\Inetpub\wwwroot\web\dataClass.vb(25) : error BC30002: Type
'SqlParameter' is
not defined.

Dim dbParam_pageNumber As New SqlParameter
~~~~~~~~~~~~
C:\Inetpub\wwwroot\web\dataClass.vb(28) : error BC30451: Name 'DbType' is
not de
clared.

dbParam_pageNumber.DbType = DbType.Int32
~~~~~~
C:\Inetpub\wwwroot\web\dataClass.vb(32) : error BC30002: Type 'IDataReader' is n
ot defined.

Dim dataReader As IDataReader = dbCommand.ExecuteReader
(CommandBehav
ior.CloseConnection)
~~~~~~~~~~~

I'm using the following Batch file to compile:

Set PATH=%SystemRoot%\Microsoft.NET\Framework\v1.1.432 2
cd c:\inetpub\wwwroot\web
vbc dataClass.vb /t:library /r:System.Web.dll /out:bin\dataClass.dll
pause
Thanks so much for any help.

--
Message posted via http://www.dotnetmonster.com

Nov 19 '05 #2
I had tried that but got the following error:

error BC30466: Namespace or type 'SqlClient' for the Imports
'System.Data.SqlClient' cannot be found

Thanks

--
Message posted via http://www.dotnetmonster.com
Nov 19 '05 #3
Hello Joe via DotNetMonster.com,

You'll also need to add a reference to System.Data.dll.

--
Matt Berther
http://www.mattberther.com
I had tried that but got the following error:

error BC30466: Namespace or type 'SqlClient' for the Imports
'System.Data.SqlClient' cannot be found

Thanks


Nov 19 '05 #4

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

Similar topics

4
by: Thomi Richards | last post by:
Hi, I'm trying to create a simple stack class using C++ and templates. Everything works well and good if I amke the class totally inline. However, as soon as I try to seperate the class into a...
24
by: Massimo Soricetti | last post by:
Hello, I'm not a C newbie, but I'm teaching C programming (well... FIRST programming and then C) to other guys these days and it's driving me to some reflexions on the language. It's not...
2
by: donkeyboy | last post by:
All, I've tried the jythonc compiler to try and create an applet to see how it works, but I get a number of Java compile errors that are way above my knowledge. Does anyone know what any of the...
2
by: TamaThps | last post by:
Hi, I'm using visual studio 2008 and normally when I get an error it shows what line it is on and which file etc. The error I'm getting I don't know how to solve or even what the problem is. This...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.