有关使用Visual_studio.net做网站的问题

zzx_2004 2007-03-24 10:28:47
大家好!我是.net的初学者。最近使用Visual Studio.net做一个电子商务网站,调试过程中我遇到了一个问题,想了很久,上网查过,也找过相关的书看了,但还是解决不了。请各位帮我看看。
我创建了一个类叫Catalog,并声明为Pubic。代码如下:
Imports System.Data.SqlClient
Public Class Catalog
Public Shared Function GetDepartments() As SqlDataReader
' Create the connection object
Dim connection As New SqlConnection(connectionString)
' Create and initialize the command object
Dim command As New SqlCommand("GetDepartments", connection)
command.CommandType = Data.CommandType.StoredProcedure
' Open the connection
connection.Open()
' Return a SqlDataReader to the calling function
Return command.ExecuteReader(Data.CommandBehavior.CloseConnection)
End Function
Private Shared ReadOnly Property connectionString() As String
Get
Return System.Configuration.ConfigurationManager.AppSettings("ConnectionString")
End Get
End Property
End Class
之后的在一个Web控件中调用,代码如下:
Public Class DepartmentsList
Inherits System.Web.UI.UserControl
#Region " Web Form Designer Generated Code "
'This call is required by the Web Form Designer.
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
End Sub
Protected WithEvents list As System.Web.UI.WebControls.DataList
'NOTE: The following placeholder declaration is required by the Web Form Designer.
'Do not delete or move it.
Private designerPlaceholderDeclaration As System.Object
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Init
'CODEGEN: This method call is required by the Web Form Designer
'Do not modify it using the code editor.
InitializeComponent()
End Sub
#End Region
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
' The departmentIndex parameter is added to the query string when
' a department link is clicked. You need this because when the
' page is reloaded, the DataList forgets which link was clicked.
Dim listIndex As String = Request.QueryString("departmentIndex")
' If listIndex has a value, this tells you that the visitor
' has clicked a department, and you inform the DataList about that
' (so it can apply the correct template for the selected item)
If Not listIndex Is Nothing Then
list.SelectedIndex = CInt(listIndex)
End If
'Create a new Catalog object
Dim catalog As New Catalog()
' GetDepartments returns a SqlDataReader object that has
' two fields: DepartmentID and Name. These fields are read in
' the SelectedItemTemplate and ItemTemplate of the DataList
list.DataSource = Catalog.GetDepartments()
' Needed to bind the child controls (the HyperLink controls)
' to the data source
list.DataBind()
End Sub
End Class
说明:红色的是错误代码

运行错误有一个:
错误 1 未定义类型“Catalog”。 D:\MyCommerceSite\JokePoint\UserControls\DepartmentsList.ascx.vb 37 28 http://localhost/JokePoint/
给出的更正提示是:
1、检查类型定义和类型引用的拼写是否相同。

2、检查引用是否可以访问该类型定义。例如,如果类型在另一个模块中且已声明为 Private,则请将该类型定义移到引用模块中或将其声明为 Public。

3、如果类型已经定义,但定义它的对象库或类型库未在 Visual Basic 中注册,则请单击“项目”菜单上的“添加引用”,然后选择适当的对象库或类型库。

经过多遍检查,最后确认第3项最有可能,可是添加的组件那么多,我不知道要选哪一项,求各位老师指点。感激不尽!
...全文
192 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

16,554

社区成员

发帖
与我相关
我的任务
社区描述
VB技术相关讨论,主要为经典vb,即VB6.0
社区管理员
  • VB.NET
  • 水哥阿乐
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧