我有这个存储过程不会返回带有@RefereeId
输出参数的getRefereeId
。有什么建议?运行此查询时,getRefereeId
没有返回任何内容
@Email nvarchar(50),
@AssignerId int,
@RefereeId Int Output,
@DateCreated Datetime,
@Active bit,
@Invitation bit
as
begin
Select @RefereeId
From Referee
Where Email = @Email
Insert Into Assignment (AssignerId, RefereeId, DateCreated, Active, Invitation)
Values (@AssignerId, @RefereeId, @DateCreated, @Active, @Invitation)
End
VB代码:
Dim strConn As String = "Data Source=mydatasource"
Dim Conn As New SqlConnection(strConn)
Dim Cmd As New SqlCommand("InviteReferee", Conn)
Cmd.CommandType = CommandType.StoredProcedure
Cmd.Parameters.Add(New SqlParameter("Email", newEmail.Text))
Cmd.Parameters.Add(New SqlParameter("Invitation", "True"))
Cmd.Parameters.Add(New SqlParameter("Active", "False"))
Cmd.Parameters.Add(New SqlParameter("AssignerId", AssignerId.Text))
Cmd.Parameters.Add(New SqlParameter("DateCreated", DateTime.Now()))
Dim getRefereeId As SqlParameter = Cmd.Parameters.Add("@RefereeId", SqlDbType.Int)
getRefereeId.Direction = ParameterDirection.Output
Conn.Open()
Cmd.ExecuteNonQuery()
答案 0 :(得分:0)
您需要实际为输出参数指定列值!
将您的代码更改为:
Select @RefereeId = SomeSuitableColumnNameHere
From dbo.Referee
Where Email = @Email
这样,您将在Referee
中选择一个列到@RefereeId
参数中,然后将其发送回VB.NET调用者。