我正在努力让查询通过网络表单运行和显示结果。它使用参数将值传递到存储过程中,但是尽管设置了 @status 值,但它似乎没有被 sp 拾取,因此不返回任何结果。我的 Vb 非常有限,我怀疑这就是问题所在。
继承人的SQL:
ALTER proc [dbo].[get_status_times]
@status nvarchar
as
select project_code, activity_code, project_date, project_time from
timesheet where status = @status
和VB
Sub detailsClicked(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) Handles listweekstatus.ItemCommand
Dim wccolumn As TableCell = e.Item.Cells(0)
' Dim timeColumn As TableCell = e.Item.Cells(1)
Dim statusColumn As TableCell = e.Item.Cells(2)
' Dim buttonColumn As TableCell = e.Item.Cells(3)
Dim wccoltext As DateTime = wccolumn.Text
' Dim timeColText As String = timeColumn.Text
Dim statusColText As String = statusColumn.Text
' Dim buttonColText As String = buttonColumn.Text
Dim myConnection As New SqlConnection(ConfigurationManager.ConnectionStrings("chronosdb").ConnectionString)
Const strSQL As String = "get_status_times"
Dim myCommand As New SqlCommand(strSQL, myConnection)
myCommand.CommandType = CommandType.StoredProcedure
myCommand.Parameters.Add("@status", SqlDbType.NVarChar)
myCommand.Parameters("@status").Value = statusColText
myCommand.Parameters("@status").Direction = ParameterDirection.Input
'Set the datagrid's datasource to the datareader and databind
myConnection.Open()
weekdetails.DataSource = myCommand.ExecuteReader(CommandBehavior.CloseConnection)
weekdetails.DataBind()
End Sub
任何帮助表示赞赏。