2011-09-25 102 views
0

我在VB.NET(.NET 3.5,SQLServer 2005)中創建CLR存儲過程。該過程具有4個BYVal參數和4個BYRef參數。它編譯並正確部署到SQL Server中,並創建一個存儲過程。 然而,當我嘗試運行它堅持傳遞的輸出參數在SP,它提供了以下錯誤.NET CLR存儲過程OUTPUT參數

我從SQL Server中運行它,如下

DECLARE @return_value INT, @outI INT, @outS爲nvarchar(4000), @outD日期時間, @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

代碼我想你忘記了錯誤消息粘貼。 – siride

+0

除了@siride評論,您如何調用存儲過程也會有所幫助。 – casperOne

回答

2

使用Out()ByRef之前的屬性如下

Imports System.Runtime.InteropServices 
… 
Public Shared Sub PriceSum (<Out()> ByRef value As SqlInt32) 
+0

謝謝Evpo解決了它 – josephj1989