|
 |
aspx thread: Class not defined error
Message #1 by rustin@e... on Thu, 23 Jan 2003 09:41:32 +0200
|
|
Hi guys hope you can help me.
I have this slight problem, I have this class file that I compiled using the
command line.
vbc /debug /nologo /t:library /out:\projects\contacts\bin\DataUtilities.dll
/r:System.dll /r:System.XMl.dll /r:System.Web.dll /r:System.Data.dll
\projects\contacts\Database.vb
This creates the DataUtilities.dll
When I try call the class in my code, I get an error that says
DataUtilities.Database not defined, this error occures on line 19, what does
this mean and how can I fix it?
viewpeople.aspx.vb
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Text
Imports System.Environment
Imports System.Web.UI
Imports System.Web.UI.WebControls
Namespace Contacts
Public Class ViewPeople
Inherits System.Web.UI.Page
Protected lblOutput As Label
Sub Page_Load(Src As Object, e As EventArgs)
Dim sdrData As SqlDataReader
Dim sb As New StringBuilder
Dim strColor As String
Dim db as New
DataUtilities.Database("server=localhost;trusted_connection=true;database=co
ntacts") 'THIS IS THE LINE WHERE THE ERROR IS OCCURING
sdrData = db.GetDataReader("SELECT * FROM tblPeople " _
& "ORDER BY LastName, FirstName")
strColor = "tabletext"
While sdrData.Read()
sb.AppendFormat("<tr class=""{0}"">" + NewLine, strColor)
sb.AppendFormat(" <td>{0}, {1}</td>" + NewLine, _
sdrData("LastName"), _
sdrData("FirstName"))
sb.AppendFormat(" <td>{0}</td>" + NewLine, sdrData("Title"))
sb.AppendFormat(" <td>{0}</td>" + NewLine, _
sdrData("CompanyName"))
sb.AppendFormat(" <td>{0}</td>" + NewLine,
sdrData("WorkPhone"))
sb.Append(" <td align=middle>")
sb.AppendFormat("<a href=""viewnotes.aspx" _
& "?pID={0}"">View Notes</a>", _
sdrData("pkPersonID"))
sb.Append(" ")
sb.AppendFormat("<a href=""viewcontacts.aspx" _
& "?pID={0}"">View Contacts</a>", _
sdrData("pkPersonID"))
sb.Append(" ")
sb.AppendFormat("<a href=""updateperson.aspx" _
& "?id={0}"">Update</a>", _
sdrData("pkPersonID"))
sb.Append(" ")
sb.AppendFormat("<a href=""deleteperson.aspx" _
& "?id={0}"">Delete</a>" + NewLine, _
sdrData("pkPersonID"))
sb.Append(" </td>" + NewLine)
sb.Append("</tr>" + NewLine)
If strColor = "tabletext" Then
strColor = "tabletext_gray"
Else
strColor = "tabletext"
End If
End While
sdrData.Close()
db.Close()
lblOutput.Text = sb.ToString()
End Sub
End Class
End Namespace
viewpeople.aspx
<%@ Page Inherits="Contacts.ViewPeople" Src="viewpeople.aspx.vb" %>
<html>
<head>
<title>Contact Manager: View All People</title>
<!--#include file="styles.css" -->
</head>
<body bgcolor="#FFFFFF">
<p class="pageheading">View All People</p>
<p class="tabletext">
<a href="addperson.aspx">Add New Person</a>
</p>
<table cellpadding="4" cellspacing="0" width="100%">
<tr class="tableheading">
<td>Name</td>
<td>Title</td>
<td>Company Name</td>
<td>Work Phone</td>
<td>Actions</td>
</tr>
<asp:label id="lblOutput" runat="server"></asp:Label>
</table>
</body>
</html>
Message #2 by "Rohit Arora" <rohit_arora@i...> on Thu, 23 Jan 2003 13:41:45 +0530
|
|
In ur code u hv to import this file.
add -- Imports Database
-----Original Message-----
From: Rustin Daniels [mailto:rustin@e...]
Sent: Thursday, January 23, 2003 1:12 PM
To: ASP.NET
Subject: [aspx] Class not defined error
Hi guys hope you can help me.
I have this slight problem, I have this class file that I compiled using the
command line.
vbc /debug /nologo /t:library /out:\projects\contacts\bin\DataUtilities.dll
/r:System.dll /r:System.XMl.dll /r:System.Web.dll /r:System.Data.dll
\projects\contacts\Database.vb
This creates the DataUtilities.dll
When I try call the class in my code, I get an error that says
DataUtilities.Database not defined, this error occures on line 19, what does
this mean and how can I fix it?
viewpeople.aspx.vb
Imports System
Imports System.Data
Imports System.Data.SqlClient
Imports System.Text
Imports System.Environment
Imports System.Web.UI
Imports System.Web.UI.WebControls
Namespace Contacts
Public Class ViewPeople
Inherits System.Web.UI.Page
Protected lblOutput As Label
Sub Page_Load(Src As Object, e As EventArgs)
Dim sdrData As SqlDataReader
Dim sb As New StringBuilder
Dim strColor As String
Dim db as New
DataUtilities.Database("server=localhost;trusted_connection=true;database=co
ntacts") 'THIS IS THE LINE WHERE THE ERROR IS OCCURING
sdrData = db.GetDataReader("SELECT * FROM tblPeople " _
& "ORDER BY LastName, FirstName")
strColor = "tabletext"
While sdrData.Read()
sb.AppendFormat("<tr class=""{0}"">" + NewLine, strColor)
sb.AppendFormat(" <td>{0}, {1}</td>" + NewLine, _
sdrData("LastName"), _
sdrData("FirstName"))
sb.AppendFormat(" <td>{0}</td>" + NewLine, sdrData("Title"))
sb.AppendFormat(" <td>{0}</td>" + NewLine, _
sdrData("CompanyName"))
sb.AppendFormat(" <td>{0}</td>" + NewLine,
sdrData("WorkPhone"))
sb.Append(" <td align=middle>")
sb.AppendFormat("<a href=""viewnotes.aspx" _
& "?pID={0}"">View Notes</a>", _
sdrData("pkPersonID"))
sb.Append(" ")
sb.AppendFormat("<a href=""viewcontacts.aspx" _
& "?pID={0}"">View Contacts</a>", _
sdrData("pkPersonID"))
sb.Append(" ")
sb.AppendFormat("<a href=""updateperson.aspx" _
& "?id={0}"">Update</a>", _
sdrData("pkPersonID"))
sb.Append(" ")
sb.AppendFormat("<a href=""deleteperson.aspx" _
& "?id={0}"">Delete</a>" + NewLine, _
sdrData("pkPersonID"))
sb.Append(" </td>" + NewLine)
sb.Append("</tr>" + NewLine)
If strColor = "tabletext" Then
strColor = "tabletext_gray"
Else
strColor = "tabletext"
End If
End While
sdrData.Close()
db.Close()
lblOutput.Text = sb.ToString()
End Sub
End Class
End Namespace
viewpeople.aspx
<%@ Page Inherits="Contacts.ViewPeople" Src="viewpeople.aspx.vb" %>
<html>
<head>
<title>Contact Manager: View All People</title>
<!--#include file="styles.css" -->
</head>
<body bgcolor="#FFFFFF">
<p class="pageheading">View All People</p>
<p class="tabletext">
<a href="addperson.aspx">Add New Person</a>
</p>
<table cellpadding="4" cellspacing="0" width="100%">
<tr class="tableheading">
<td>Name</td>
<td>Title</td>
<td>Company Name</td>
<td>Work Phone</td>
<td>Actions</td>
</tr>
<asp:label id="lblOutput" runat="server"></asp:Label>
</table>
</body>
</html>
|
|
 |