我很难通过网络表单查询运行和显示结果。它使用一个参数将值传递给存储过程,但是虽然设置了@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
任何帮助表示感谢。
答案 0 :(得分:2)
尝试在proc中更改参数声明:
@status nvarchar(200) --For example
现有声明将修改您对第一个字符的输入:
例如以下代码:
create proc paramtest (@param nvarchar)
as
begin
select @param
end
go
exec paramtest 'foobar'
只需选择f