473,795 Members | 2,867 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Common Functions

Hi,

I've created a class that contains a common function. When I try to invoke
the function or method, I get the error:
BC30451: Name 'dataClass' is not declared.

The class file dataClass.vb contains the following:
Imports System
Namespace MySpace
Public Class dataClass
Public Shared Function GetPage(ByVal pageNumber As Integer, ByVal
lessonNumber As Integer, ByVal courseNumber As Integer) As
System.Data.IDa taReader
Dim strConnection As String
strConnection = ConfigurationSe ttings.AppSetti ngs
("ConnectionStr ing")

Dim dbConnection As System.Data.IDb Connection = New
System.Data.Sql Client.SqlConne ction(strConnec tion)

Dim queryString As String = "SELECT [tblPage].*, [tblLesson].
[LessonNumber], [tblCourse].[CourseNumber] FROM [tblPage], [tblLesson],
[tblCourse] WHERE (([tblPage].[Pa"& _
"geNumber] = @PageNumber) AND ([tblLesson].[LessonNumber] =
@LessonNumber) AND (["& _
"tblCourse].[CourseNumber] = @CourseNumber)) AND
tblPage.lessonI D = tblLesson.lesso nID AND tblLesson.Cours eID =
tblCourse.Cours eID"
Dim dbCommand As System.Data.IDb Command = New
System.Data.Sql Client.SqlComma nd
dbCommand.Comma ndText = queryString
dbCommand.Conne ction = dbConnection

Dim dbParam_pageNum ber As System.Data.IDa taParameter = New
System.Data.Sql Client.SqlParam eter
dbParam_pageNum ber.ParameterNa me = "@PageNumbe r"
dbParam_pageNum ber.Value = pageNumber
dbParam_pageNum ber.DbType = System.Data.DbT ype.Int32
dbCommand.Param eters.Add(dbPar am_pageNumber)
Dim dbParam_lessonN umber As System.Data.IDa taParameter = New
System.Data.Sql Client.SqlParam eter
dbParam_lessonN umber.Parameter Name = "@LessonNum ber"
dbParam_lessonN umber.Value = lessonNumber
dbParam_lessonN umber.DbType = System.Data.DbT ype.Int32
dbCommand.Param eters.Add(dbPar am_lessonNumber )
Dim dbParam_courseN umber As System.Data.IDa taParameter = New
System.Data.Sql Client.SqlParam eter
dbParam_courseN umber.Parameter Name = "@CourseNum ber"
dbParam_courseN umber.Value = courseNumber
dbParam_courseN umber.DbType = System.Data.DbT ype.Int32
dbCommand.Param eters.Add(dbPar am_courseNumber )

dbConnection.Op en
Dim dataReader As System.Data.IDa taReader =
dbCommand.Execu teReader(System .Data.CommandBe havior.CloseCon nection)

Return dataReader
End Function
End Class
End Namespace
When trying to invoke it, I use:
<ASP:Repeater id="RepeaterPag eText" runat="server" DataSource="<%#
dataClass.GetPa ge(1,1,1) %>">
<ItemTemplate >
<%# DataBinder.Eval (Container.Data Item, "pageText") %>
</ItemTemplate>
</ASP:Repeater>

Am I supposed to declare the class in the page I'm going to use? The class
file exists in the root of the application.

Thanks

--
Message posted via http://www.dotnetmonster.com
Nov 19 '05 #1
3 1766
Hi Pete:

If your class is being built as part of the same project, you'll just
need an Imports for the namespace in your aspx, or fully qualify the
type name.

<%@ Import namespace="MySp ace" %>

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Mon, 14 Mar 2005 23:54:57 GMT, "Pete via DotNetMonster.c om"
<fo***@DotNetMo nster.com> wrote:
Hi,

I've created a class that contains a common function. When I try to invoke
the function or method, I get the error:
BC30451: Name 'dataClass' is not declared.

The class file dataClass.vb contains the following:
Imports System
Namespace MySpace
Public Class dataClass
Public Shared Function GetPage(ByVal pageNumber As Integer, ByVal
lessonNumber As Integer, ByVal courseNumber As Integer) As
System.Data.ID ataReader
Dim strConnection As String
strConnection = ConfigurationSe ttings.AppSetti ngs
("ConnectionSt ring")

Dim dbConnection As System.Data.IDb Connection = New
System.Data.Sq lClient.SqlConn ection(strConne ction)

Dim queryString As String = "SELECT [tblPage].*, [tblLesson].
[LessonNumber], [tblCourse].[CourseNumber] FROM [tblPage], [tblLesson],
[tblCourse] WHERE (([tblPage].[Pa"& _
"geNumber] = @PageNumber) AND ([tblLesson].[LessonNumber] =
@LessonNumbe r) AND (["& _
"tblCourse].[CourseNumber] = @CourseNumber)) AND
tblPage.lesson ID = tblLesson.lesso nID AND tblLesson.Cours eID =
tblCourse.Cour seID"
Dim dbCommand As System.Data.IDb Command = New
System.Data.Sq lClient.SqlComm and
dbCommand.Comma ndText = queryString
dbCommand.Conne ction = dbConnection

Dim dbParam_pageNum ber As System.Data.IDa taParameter = New
System.Data.Sq lClient.SqlPara meter
dbParam_pageNum ber.ParameterNa me = "@PageNumbe r"
dbParam_pageNum ber.Value = pageNumber
dbParam_pageNum ber.DbType = System.Data.DbT ype.Int32
dbCommand.Param eters.Add(dbPar am_pageNumber)
Dim dbParam_lessonN umber As System.Data.IDa taParameter = New
System.Data.Sq lClient.SqlPara meter
dbParam_lessonN umber.Parameter Name = "@LessonNum ber"
dbParam_lessonN umber.Value = lessonNumber
dbParam_lessonN umber.DbType = System.Data.DbT ype.Int32
dbCommand.Param eters.Add(dbPar am_lessonNumber )
Dim dbParam_courseN umber As System.Data.IDa taParameter = New
System.Data.Sq lClient.SqlPara meter
dbParam_courseN umber.Parameter Name = "@CourseNum ber"
dbParam_courseN umber.Value = courseNumber
dbParam_courseN umber.DbType = System.Data.DbT ype.Int32
dbCommand.Param eters.Add(dbPar am_courseNumber )

dbConnection.Op en
Dim dataReader As System.Data.IDa taReader =
dbCommand.Exec uteReader(Syste m.Data.CommandB ehavior.CloseCo nnection)

Return dataReader
End Function
End Class
End Namespace
When trying to invoke it, I use:
<ASP:Repeate r id="RepeaterPag eText" runat="server" DataSource="<%#
dataClass.GetP age(1,1,1) %>">
<ItemTemplate >
<%# DataBinder.Eval (Container.Data Item, "pageText") %>
</ItemTemplate>
</ASP:Repeater>

Am I supposed to declare the class in the page I'm going to use? The class
file exists in the root of the application.

Thanks


Nov 19 '05 #2
Thanks. I tried adding the namespace but it still comes up that the method
or function is undeclared. Do I need to add a path to the namespace? How
would you fully qualify the type name?

--
Message posted via http://www.dotnetmonster.com
Nov 19 '05 #3
Hi Pete:

The <%@ Import namespace="MySp ace" %> directive will include the
namespace.

Are you using Visual Studio .NET to build - or another tool? Make sure
the class is compiled by including the file in your project. Now that
I read your message again, it sounds like you are trying to include
the class by just placing the file in the root directory - but you''ll
need it to compile too.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Tue, 15 Mar 2005 04:01:39 GMT, "Pete via DotNetMonster.c om"
<fo***@DotNetMo nster.com> wrote:
Thanks. I tried adding the namespace but it still comes up that the method
or function is undeclared. Do I need to add a path to the namespace? How
would you fully qualify the type name?


Nov 19 '05 #4

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

Similar topics

6
1675
by: Don Wash | last post by:
Hi All! I'm developing ASP.NET pages using VB.NET language. My background is VB6 and ASP3. Right now, I'm evaluating strategies on creating reusable and common functions and methods for ASP.NET. In ASP 3, it was nothing more than functions and methods coded in #Include Files. Now ASP.NET offers features such as Page Inheritance and full software development support. So I'm just wondering, what should I do if I have 5 functions, that...
5
3199
by: wrecker | last post by:
Hi all, I have a few common methods that I need to use at different points in my web application. I'm wondering where the best place would be to put these? I think that I have three options. 1. I can create a common module like common.vb in my project and put all the functions in there. 2. Create a utility class and create the common functions as shared
6
1534
by: Don Wash | last post by:
Hi All! I'm developing ASP.NET pages using VB.NET language. My background is VB6 and ASP3. Right now, I'm evaluating strategies on creating reusable and common functions and methods for ASP.NET. In ASP 3, it was nothing more than functions and methods coded in #Include Files. Now ASP.NET offers features such as Page Inheritance and full software development support. So I'm just wondering, what should I do if I have 5 functions, that...
5
1392
by: jonkersbart | last post by:
Dear, I have wrote a script and want to group some functions of the script in a separate modulo so that I can import the module in other scripts and use the same functions there.. The problem is that the common functions need access to some global variables defined in the script. Python uses different namespaces for different modules so I can't access the variables of the script in the module.
6
11498
Markus
by: Markus | last post by:
Things to discuss: Headers What are they? What does PHP have to do with headers? Why can they only be sent before any output? Common causes
0
9673
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9522
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10448
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10217
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9046
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7544
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4114
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3730
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2922
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.