Wrox Programmer Forums
Go Back   Wrox Programmer Forums > .NET > Other .NET > General .NET
General .NET For general discussion of MICROSOFT .NET topics that don't fall within any of the other .NET forum subcategories or .NET language forums.  If your question is specific to a language (C# or Visual Basic) or type of application (Windows Forms or ASP.Net) try an applicable forum category. ** PLEASE BE SPECIFIC WITH YOUR QUESTION ** When posting here, provide details regarding the Microsoft .NET language you are using and/or what type of application (Windows/Web Forms, etc) you are working in, if applicable to the question. This will help others answer the question without having to ask.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the General .NET section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old March 16th, 2005, 12:36 AM
Registered User
Join Date: Mar 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Errors when Compiling a Class File


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 System.Configuration
Imports System.Data.SqlClient
Imports Microsoft.VisualBasic
Imports System.Web

Namespace Data

Public Class dataClass

       Public Shared Function GetPage(ByVal pageNumber As Integer) As

           Dim strConnection As String
           strConnection = ConfigurationSettings.AppSettings

           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

           Dim dataReader As IDataReader = dbCommand.ExecuteReader

           Return dataReader

       End Function

End Class
End Namespace

These are the errors I receive:

C:\Inetpub\wwwroot\web\dataClass.vb(12) :
error BC30466: Namespace or type 'SqlClient' for the Imports
'System.Data.SqlClient' cannot be found

error BC30002: Type 'IDataReader'
is not defined.

      Public Shared Function GetPage(ByVal pageNumber As Integer) As

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

           strConnection = ConfigurationSettings.AppSettings

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

           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

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

Thanks so much for any help.
Old March 16th, 2005, 01:57 AM
Friend of Wrox
Join Date: Oct 2003
Posts: 326
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Santhi Send a message via MSN to Santhi

Check this link to resolve your problem...The most likely occur of this error when u misspell the namespace or do not have reference to the assembly where namespace resides.


Similar Threads
Thread Thread Starter Forum Replies Last Post
Errors Compiling Jiffyman C++ Programming 5 October 16th, 2008 01:27 AM
compiling class sarah lee ASP.NET 1.0 and 1.1 Basics 3 September 14th, 2006 10:49 AM
errors compiling on beta2 gaid BOOK: ASP.NET Website Programming Problem-Design-Solution 3 February 21st, 2005 12:25 AM
Using a class without compiling it pdreply ASP.NET 1.0 and 1.1 Basics 8 April 5th, 2004 02:51 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.