过程 'GetCategoriesInDepartment' 需要参数 '@AreaID',但未提供该参数。
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。异常详细信息: System.Data.SqlClient.SqlException: 过程 'GetCategoriesInDepartment' 需要参数 '@AreaID',但未提供该参数。
源错误:
|
|
GetCategoriesInDepartment函数
Public Function GetCategoriesInDepartment(ByVal departmentId As String) As SqlDataReader
Dim connection As New SqlConnection(connectionString)
Dim command As New SqlCommand("GetCategoriesInDepartment", connection)
command.CommandType = CommandType.StoredProcedure
command.Parameters.Add("@AreaID", SqlDbType.Int, 4)
command.Parameters("@AreaID").Value = departmentId
connection.Open()
Return command.ExecuteReader(CommandBehavior.CloseConnection)
End Function
GetCategoriesInDepartment存储过程
ALTER PROCEDURE GetCategoriesInDepartment
(@AreaID int)
AS
SELECT BrandID,BrandName
FROM Category
WHERE AreaID=@AreaID
RETURN
用到函数的地方
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'在此处放置初始化页的用户代码
Dim departmentId As String = Request.Params("AreaID")
Dim listIndex As String = Request.Params("CategoryIndex")
If Not listIndex Is Nothing Then
list.SelectedIndex = CInt(listIndex)
End If
Dim catalog As New Catalog
list.DataSource = catalog.GetCategoriesInDepartment(departmentId)
list.DataBind()
End Sub