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

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.IDataReader
Dim strConnection As String
strConnection = ConfigurationSettings.AppSettings
("ConnectionString")

Dim dbConnection As System.Data.IDbConnection = New
System.Data.SqlClient.SqlConnection(strConnection)

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.lessonID = tblLesson.lessonID AND tblLesson.CourseID =
tblCourse.CourseID"
Dim dbCommand As System.Data.IDbCommand = New
System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

Dim dbParam_pageNumber As System.Data.IDataParameter = New
System.Data.SqlClient.SqlParameter
dbParam_pageNumber.ParameterName = "@PageNumber"
dbParam_pageNumber.Value = pageNumber
dbParam_pageNumber.DbType = System.Data.DbType.Int32
dbCommand.Parameters.Add(dbParam_pageNumber)
Dim dbParam_lessonNumber As System.Data.IDataParameter = New
System.Data.SqlClient.SqlParameter
dbParam_lessonNumber.ParameterName = "@LessonNumber"
dbParam_lessonNumber.Value = lessonNumber
dbParam_lessonNumber.DbType = System.Data.DbType.Int32
dbCommand.Parameters.Add(dbParam_lessonNumber)
Dim dbParam_courseNumber As System.Data.IDataParameter = New
System.Data.SqlClient.SqlParameter
dbParam_courseNumber.ParameterName = "@CourseNumber"
dbParam_courseNumber.Value = courseNumber
dbParam_courseNumber.DbType = System.Data.DbType.Int32
dbCommand.Parameters.Add(dbParam_courseNumber)

dbConnection.Open
Dim dataReader As System.Data.IDataReader =
dbCommand.ExecuteReader(System.Data.CommandBehavio r.CloseConnection)

Return dataReader
End Function
End Class
End Namespace
When trying to invoke it, I use:
<ASP:Repeater id="RepeaterPageText" runat="server" DataSource="<%#
dataClass.GetPage(1,1,1) %>">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "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 1752
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="MySpace" %>

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

On Mon, 14 Mar 2005 23:54:57 GMT, "Pete via DotNetMonster.com"
<fo***@DotNetMonster.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.IDataReader
Dim strConnection As String
strConnection = ConfigurationSettings.AppSettings
("ConnectionString")

Dim dbConnection As System.Data.IDbConnection = New
System.Data.SqlClient.SqlConnection(strConnection )

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.lessonID = tblLesson.lessonID AND tblLesson.CourseID =
tblCourse.CourseID"
Dim dbCommand As System.Data.IDbCommand = New
System.Data.SqlClient.SqlCommand
dbCommand.CommandText = queryString
dbCommand.Connection = dbConnection

Dim dbParam_pageNumber As System.Data.IDataParameter = New
System.Data.SqlClient.SqlParameter
dbParam_pageNumber.ParameterName = "@PageNumber"
dbParam_pageNumber.Value = pageNumber
dbParam_pageNumber.DbType = System.Data.DbType.Int32
dbCommand.Parameters.Add(dbParam_pageNumber)
Dim dbParam_lessonNumber As System.Data.IDataParameter = New
System.Data.SqlClient.SqlParameter
dbParam_lessonNumber.ParameterName = "@LessonNumber"
dbParam_lessonNumber.Value = lessonNumber
dbParam_lessonNumber.DbType = System.Data.DbType.Int32
dbCommand.Parameters.Add(dbParam_lessonNumber)
Dim dbParam_courseNumber As System.Data.IDataParameter = New
System.Data.SqlClient.SqlParameter
dbParam_courseNumber.ParameterName = "@CourseNumber"
dbParam_courseNumber.Value = courseNumber
dbParam_courseNumber.DbType = System.Data.DbType.Int32
dbCommand.Parameters.Add(dbParam_courseNumber)

dbConnection.Open
Dim dataReader As System.Data.IDataReader =
dbCommand.ExecuteReader(System.Data.CommandBehavi or.CloseConnection)

Return dataReader
End Function
End Class
End Namespace
When trying to invoke it, I use:
<ASP:Repeater id="RepeaterPageText" runat="server" DataSource="<%#
dataClass.GetPage(1,1,1) %>">
<ItemTemplate>
<%# DataBinder.Eval(Container.DataItem, "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="MySpace" %> 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.com"
<fo***@DotNetMonster.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
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....
5
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. ...
6
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....
5
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...
6
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
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: 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
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
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
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,...
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.