我在VB.NET(.NET 3.5,SQLServer 2005)中创建了一个CLR存储过程。该过程有4个BYVal参数和4个BYRef参数。它可以正确地编译和部署到SQL Server中,并创建一个存储过程。 但是,当我尝试运行SP时,它坚持要传递OUTPUT参数。它会出现以下错误
我从SQL Server运行它,如下面
DECLARE @return_value int, @outI int, @outS nvarchar(4000), @outD datetime, @outB位
EXEC @return_value = [dbo].[ProofOfConcept]
@inI = 23,
@inS = N'john',
@inD = N'12/12/2009',
@inB = 1,
@outI = @outI OUTPUT,
@outS = @outS OUTPUT,
@outD = @outD OUTPUT,
@outB = @outB OUTPUT
'TestProc'失败,因为参数5不允许为空。
我的VB.NET程序声明在
之下 Public Shared Sub TestProc(ByVal inI As Integer, ByVal inS As String, ByVal inD As DateTime, ByVal inB As Boolean, _
ByRef outI As Integer, ByRef outS As String, ByRef outD As DateTime, ByRef outB As Boolean)
答案 0 :(得分:2)
在Out()
之前使用ByRef
属性,如下面的代码
Imports System.Runtime.InteropServices
…
Public Shared Sub PriceSum ( <Out()> ByRef value As SqlInt32)