2013-01-13 1 views
0

을 반환하지 않는 저장된 SQL 서버 2005/w 최신 PetaPoco w 다음 코드/:PetaPoco 출력 파람에서 절차가 사용

Dim count = New SqlParameter("@Count", System.Data.ParameterDirection.Output) 
    count.DbType = Data.DbType.Int32 

    Dim results = db.Query(Of User)(";exec SearchUserPaged @@[email protected], @@[email protected], @@[email protected], @@[email protected], @@[email protected] OUT", 
            New With {.page = pageEx, .maximumRows = maximumRowIndex, .ClientID = Me.ClientID, .SortExp = sortExpression, .Count = count}).ToList() 

    'Dim results = db.EDPEntities.Query(Of User)(";exec SearchUserPaged @@[email protected], @@[email protected], @@[email protected], @@[email protected], @@[email protected] OUTPUT", 
    '         pageEx, maximumRowIndex, Me.ClientID, sortExpression, count).ToList() 

    If IsDBNull(count.Value) Then 
     Me.Count = 0 
    Else 
     Me.Count = count.Value 
    End If 

그러나 출력 PARAM은 항상 그렇게 확신 PetaPoco에 예쁜 새 0의 값을 돌려줍니다 내가 뭔가 명백한 것을 놓치고 있다면. 나는 올바른 값이 반환됩니다 SELECT @4

DECLARE @0 int,@1 int,@2 int,@3 nvarchar(4000),@4 int 
SET @0=1 
SET @1=25 
SET @2=10145 
SET @3=NULL 
SET @4=2 
exec SearchUserPaged @[email protected], @[email protected], @[email protected], @[email protected], @[email protected] OUT 

SELECT @4 

: 여기

쿼리 분석기에서 잘 실행 상세 설명에 의해 생성 된 SQL입니다.

답변

0

이것은 일 (확실하지 왜) :

Dim count = New SqlParameter("@Count", System.Data.SqlDbType.Int) 
    count.Direction = System.Data.ParameterDirection.Output 
    count.Value = DBNull.Value 

    Dim results = db.Query(Of User)(";exec SearchUserPaged @@[email protected], @@[email protected], @@[email protected], @@[email protected], @@[email protected] OUT", New With { _ 
     Key .page = pageEx, _ 
     Key .maximumRows = maximumRowIndex, _ 
     Key .ClientID = ClientID, _ 
     Key .SortExp = sortExpression, _ 
     Key .Count = count _ 
    }).ToList() 

    If IsDBNull(count.Value) Then 
     Me.Count = 0 
    Else 
     Me.Count = count.Value 
    End If 
+0

무슨 차이가 도움이 파람

Dim count = New SqlParameter("@Count", System.Data.SqlDbType.Int) count.Direction = System.Data.ParameterDirection.Output count.Value = DBNull.Value -- this fixed the error. 

희망의 기본 가치를 생각? – Schotime

0

내가 때문에이