vb.net调用sql server存储过程调用问题,为什么总是出错呢
存储过程:
ALTER PROCEDURE SP_Ck_Set_Size_Stkbn
@RSLTNO VARCHAR(9)
,@RSLT VARCHAR(1)
,@MSGID VARCHAR(8)
,@DBUSER VARCHAR(10)
,@RSLTDTLNO VARCHAR(9) OUTPUT
,@COUNTER INT OUTPUT
AS
BEGIN
--do something
END
-----------------------------------
参数定义方法:
Public Shared Function MakeParameter(ByVal pParameterName As String _
, ByVal pSqlDbType As SqlDbType _
, ByVal pSize As Integer _
, ByVal pParameterDirection As ParameterDirection _
, Optional ByVal pValue As Object = Nothing) As SqlParameter
Dim retParam As New SqlParameter(pParameterName, pSqlDbType, pSize)
retParam.Direction = pParameterDirection
retParam.Value = IIf((pValue Is Nothing), vbNull.Variant, pValue)
Return retParam
End Function
--------------------------------------
With sqlcmd
.CommandType = CommandType.StoredProcedure
.CommandText = "SP_Ck_Set_Size_Stkbn "
.Parameters.Add(Common.MakeParameter( "@RSLTNO ", _
SqlDbType.VarChar, 9, ParameterDirection.Input, SumNo))
.Parameters.Add(Common.MakeParameter( "@RSLT ", _
SqlDbType.VarChar, 1, ParameterDirection.Input, Integer.Parse(RCRD_RSLT.ERR).ToString()))
.Parameters.Add(Common.MakeParameter( "@MSGID ", _
SqlDbType.VarChar, 8, ParameterDirection.Input, "MCBE0004 "))
.Parameters.Add(Common.MakeParameter( "@DBUSER ", _
SqlDbType.VarChar, 10, ParameterDirection.Input, User))
.Parameters.Add(Common.MakeParameter( "@RSLTDTLNO ", _
SqlDbType.VarChar, 9, ParameterDirection.Input, dtlNo))
rtrn = .ExecuteNonQuery()
If rtrn = GDCDBUtil.UPDATE_NG Then
Common.OutSysMessage( "MCBE0004 ", "jp ", SystemLogPath)
Return GDCDBUtil.UPDATE_NG
End If
End With
-------------------------------------
为什么总是返回-1呢,哪错了?
[解决办法]
rtrn = .ExecuteNonQuery()
[解决办法]
很可能参数传递的有问题
[解决办法]
GDCDBUtil.UPDATE_NG 方法怎么写的?
[解决办法]
好象直接用EXEC就可以了吧,传入一条SQL 语句