Quantcast
Channel: VBForums - Visual Basic 6 and Earlier
Viewing all articles
Browse latest Browse all 21237

how is this possible too many arguments in stored procedure from ADO ?

$
0
0
On the first pass it works and then on the second pass it blows up right at the execute statement

How and why would it complain that there are too many arguments passed to the stored proc to execute ?
Code:


Dim cmd As ADODB.Command
Set cmd = New ADODB.Command
Dim objParam As ADODB.Parameter

Set cn = New ADODB.Connection
With cn
    .Open strConnectionString
End With

Do While rsTemp.RecordCount > 0
lngTranKey = rsTemp(0)
 lngNoteKey = rsTemp(1)

Set rs = cn.Execute("SELECT fldAccountKey, fldNoteKey, fldTranKey from dbo.tblTransDetail where fldAccountKey = " & lngAccKey & " and fldNoteKey = " & lngNoteKey & "AND fldAccountingPeriod <= '" & strAccReconPeriod & "'")
'Set rs = cn.Execute("SELECT  t1.fldNoteKey, t2.fldTranKey from dbo.tblNote t1 inner join dbo.tblTransDetail t2 on t1.fldNoteKey = t2.fldNoteKey where  fldAccountKey = " & lngAccKey & "")

With cmd
    .CommandText = "spPanLetterUpdate"
    .CommandType = adCmdStoredProc
    .ActiveConnection = cn
    Set objParam = .CreateParameter("fldAccountKey", adBigInt, adParamInput, 6, lngAccKey)
    .Parameters.Append objParam
    Set objParam = .CreateParameter("fldNoteKey", adBigInt, adParamInput, 6, lngNoteKey)
    .Parameters.Append objParam
    Set objParam = .CreateParameter("fldTranKey", adBigInt, adParamInput, 6, lngTranKey)
    .Parameters.Append objParam

End With

If Not (rs.eof And rs.BOF) Then
    Do While Not rs.eof

        lngNoteKey = rs.Fields("fldNoteKey")
        lngTranKey = rs.Fields("fldTranKey")
        lngAccKey = rs.Fields("fldAccountKey")

        With cmd
            .Parameters(0).Value = lngAccKey
            .Parameters(1).Value = lngNoteKey
            .Parameters(2).Value = lngTranKey
          .Execute
        End With
        rs.MoveNext
    Loop
Else
    MsgBox "No Records are available for processing"
End If
rsTemp.MoveNext
Loop
    rs.Close
    rsTemp.Close
    Set rs = Nothing
    Set rsTemp = Nothing

oh and rstemp that is declared before hand is simply this

Code:

Dim sqlTemp As String
sqlTemp = "SELECT fldTranKey, fldNoteKey FROM tblTransDetail WHERE " & _
"fldAccountKey = " & lngAccKey & " AND fldAppliedFlag IN " & _
"(1, 3) AND fldAccountingPeriod <= '" & strAccReconPeriod & "' "
rsTemp.Open sqlTemp, cn, adOpenKeyset, adLockOptimistic
intCheckPointNum = 5


Viewing all articles
Browse latest Browse all 21237

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>