Hello,
I have the following code that executes a Stored Procedure in Sybase throught VBA.
Sub GetInfo()
Dim rstRUB As ADODB.Recordset
Dim strRUB As String
Dim strcnn As String
Dim productType As String
Dim DealId As String
strcnn = "DSN=KONDOR_QUA;DATABASE=Kustom;UID=odbcuser;PWD=odbcuser123;"
Set cnn = New ADODB.Connection
cnn.Open strcnn
Set rstRUB = New ADODB.Recordset
Set ws = Workbooks("BODN_CPOTC.xls").Sheets("BODN_CPOTC")
Dim row As Long
row = 5
While ws.Cells(row, 1) <> ""
productType = ws.Cells(row, 1)
DealId = ws.Cells(row, 3)
Set cmd = New ADODB.Command
With cmd
.CommandText = "[Proc_BO_Deriv_AFOFLD]"
.ActiveConnection = cnn
.CommandType = adCmdStoredProc
'.Parameters.Append .CreateParameter("@valueD", adDate, adParamInput, , strDate)
'.Parameters.Append .CreateParameter("@maturityD", adDate, adParamInput, , Format$("20100504", "YYYYMMDD"))
.Parameters.Append .CreateParameter("@tipoProduto", adVarChar, adParamInput, 9, productType)
.Parameters.Append .CreateParameter("@dealId", adInteger, adParamInput, 0, DealId)
End With
rstRUB.Open cmd.Execute
If rstRUB.EOF = False Then
ws.Cells(row, 5) = rstRUB.Fields(0).Value
ws.Cells(row, 6) = rstRUB.Fields(1).Value
ws.Cells(row, 7) = rstRUB.Fields(2).Value
ws.Cells(row, 8) = rstRUB.Fields(3).Value
ws.Cells(row, 9) = rstRUB.Fields(4).Value
ws.Cells(row, 10) = rstRUB.Fields(5).Value
ws.Cells(row, 11) = rstRUB.Fields(6).Value
ws.Cells(row, 12) = rstRUB.Fields(7).Value
ws.Cells(row, 13) = rstRUB.Fields(8).Value
ws.Cells(row, 14) = rstRUB.Fields(9).Value
ws.Cells(row, 15) = rstRUB.Fields(10).Value
ws.Cells(row, 16) = rstRUB.Fields(11).Value
ws.Cells(row, 17) = rstRUB.Fields(12).Value
ws.Cells(row, 18) = rstRUB.Fields(13).Value
ws.Cells(row, 19) = rstRUB.Fields(14).Value
ws.Cells(row, 20) = rstRUB.Fields(15).Value
ws.Cells(row, 21) = rstRUB.Fields(16).Value
ws.Cells(row, 22) = rstRUB.Fields(17).Value
ws.Cells(row, 23) = rstRUB.Fields(18).Value
ws.Cells(row, 24) = rstRUB.Fields(19).Value
ws.Cells(row, 25) = rstRUB.Fields(20).Value
ws.Cells(row, 26) = rstRUB.Fields(21).Value
ws.Cells(row, 27) = rstRUB.Fields(22).Value
ws.Cells(row, 28) = rstRUB.Fields(23).Value
ws.Cells(row, 29) = rstRUB.Fields(24).Value
ws.Cells(row, 30) = rstRUB.Fields(25).Value
ws.Cells(row, 31) = rstRUB.Fields(26).Value
ws.Cells(row, 32) = rstRUB.Fields(27).Value
Else
ws.Cells(row, 5) = "Deal Not Found"
End If
row = row + 1
Wend
End Sub
The first Stored Procedure Execution works well, but when it goes for the second
rstRUB.Open cmd.Execute
the program does not end..
I allready switched arguments (the first ones with the second one) and the program won't end at the second time.
Do you know what am I doing wrong?
Thanks in advance!