我在 SQL Server 2008 中有以下存储过程,它不会在 SQL 中生成任何错误,但会在 Web 应用程序中生成一个声明“'GetGenInfo_Delete01_01_22' 需要参数'@FPath',未提供”。我在 SQL 方面相当新手,但我想做的是在删除行之前将一个字段返回到 VB.NET。任何建议都会非常有帮助。
ALTER Procedure [dbo].[GetGenInfo_Delete01_01_22]
@IDX int,
@FPath varchar(100) OUTPUT
AS
Begin
SELECT @FPath = (SELECT FilePath FROM GenInfo_E1_01_22 Where ID=@IDX)
DELETE
FROM GenInfo_E1_01_22
WHERE ID = @IDX
END
这是调用存储过程的VB代码
Using con As New SqlConnection(connstr)
Using cmd As New SqlCommand()
cmd.CommandType = CommandType.StoredProcedure
cmd.CommandText = "GetGenInfo_Delete01_01_22"
cmd.Parameters.Add("IDX", ID)
Dim returnParameter = cmd.Parameters.Add("@FPath", SqlDbType.VarChar)
returnParameter.Direction = ParameterDirection.ReturnValue
cmd.Connection = con
con.Open()
GridView1.DataSource = cmd.ExecuteReader()
GridView1.DataBind()
con.Close()
End Using
End Using