OUT oName字符(20)) LANGUAGE SQL BEGIN ATOMIC DECLARE sName CHAR(20) ; SET sName =(SELECT ADADTX ||'',''|| ADAETX FROM MAILIB.UUADCPP WHERE ADAANB = pContactId); SET oName = sName; END 我的VB代码如下: Public函数Call_sp_test(con as ADODB.Connection, ByVal sContactId As String)As String On Error GoTo ErrHandler Dim sName As String Dim cmd As New ADODB.Command Dim rst as new ADODB.Recordset Dim P1 As New ADODB.Parameter Dim P2 As New ADODB.Parameter 设置cmd.ActiveConnection = con cmd.CommandText =" {CALL NORM.npn_test2(? ,?)}" cmd.CommandType = adCmdText ''cmd.CommandType = adCmdStoredProc cmd.Parameters.Refresh ''cmd.Parameters(" pContactId")。Value = sContactId cmd.Prepared = True sName =" " '40个空格 P1.Direction = adParamInput P1.Type = adChar P1.Size = 6 P1.Name =" ContactId" P1.Value =" 000006" P1.Direction = adParamReturnValue P2.Type = adChar P2.Name =" Name" P2.Size = 40 P2.Value = sName cmd.Parameters.Append P1 cmd.Parameters.Append P2 ''cmd.Execute rst.Open cmd< - 这里发生错误 sName = cmd.Parameters(" oName")。值 Call_sp_test = cmd.Parameters(" oName")。值 rst.Close Set rst = Nothing Set cmd = Nothing ErrHandler: MsgBox"错误代码:" &安培; Err.Number& vbNewLine& _ "说明:" &安培; Err.Description& vbNewLine& _ "来源:" &安培; Err.Source,vbOKOnly + vbCritical Err.Clear ''设置Call​​_sp_test = Nothing 结束功能 有没有人遇到过这个问题?我在这里错过了什么? 感谢所有回复! 欢呼, CCSorry, I accidently sent this before finishing...Please excuse the cross-post but I am unsure which group my problem pertainsto.As I was saying, when I try to execute my stored proc, I get the followingerror:"Parameter type cannot be determined for at least one variantparameter."My proc is quite simple:CREATE PROCEDURE NORM.npn_test2( IN pContactId character(3),OUT oName character(20))LANGUAGE SQLBEGIN ATOMICDECLARE sName CHAR(20);SET sName = (SELECT ADADTX || '', '' || ADAETX FROM MAILIB.UUADCPP WHEREADAANB = pContactId);SET oName = sName;ENDMy VB code looks like:Public Function Call_sp_test(con As ADODB.Connection, ByVal sContactId AsString) As StringOn Error GoTo ErrHandlerDim sName As StringDim cmd As New ADODB.CommandDim rst As New ADODB.RecordsetDim P1 As New ADODB.ParameterDim P2 As New ADODB.ParameterSet cmd.ActiveConnection = concmd.CommandText = "{CALL NORM.npn_test2(?,?)}"cmd.CommandType = adCmdText''cmd.CommandType = adCmdStoredProccmd.Parameters.Refresh''cmd.Parameters("pContactId").Value = sContactIdcmd.Prepared = TruesName = " " ''40 spacesP1.Direction = adParamInputP1.Type = adCharP1.Size = 6P1.Name = "ContactId"P1.Value = "000006"P1.Direction = adParamReturnValueP2.Type = adCharP2.Name = "Name"P2.Size = 40P2.Value = sNamecmd.Parameters.Append P1cmd.Parameters.Append P2''cmd.Executerst.Open cmd <- error occurs heresName = cmd.Parameters("oName").ValueCall_sp_test = cmd.Parameters("oName").Valuerst.CloseSet rst = NothingSet cmd = NothingErrHandler:MsgBox "Error Code: " & Err.Number & vbNewLine & _"Description: " & Err.Description & vbNewLine & _"Source: " & Err.Source, vbOKOnly + vbCriticalErr.Clear''Set Call_sp_test = NothingEnd FunctionHas anyone run into this problem before? What am I missing here?Thanks for all replies!cheers,CC 这篇关于存储过程错误 - ADO和DB2的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-31 19:25