Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1074257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:06:02+00:00 2026-05-16T21:06:02+00:00

I have the following code that executes a Stored Procedure in Sybase throught VBA.

  • 0

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=...;DATABASE=...;UID=...;PWD=...;"
    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!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T21:06:02+00:00Added an answer on May 16, 2026 at 9:06 pm

    Not sure why Set rstRUB = cmd.Execute would give a compile error…

    you can also try a call like this:

    rstRUB.Open cmd
    

    No need to call the cmd’s execute method within the Open command, since the Open command triggers the query execution. Here is a link to the recordset open command: http://msdn.microsoft.com/en-us/library/ms675544(VS.85).aspx

    Might also help to clear the memory of the cmd and rstRUB objects after you increment the row count to get ready for the next loop.

    Set cmd = Nothing
    Set rstRUB = Nothing
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following code that executes a C++ program and outputs it :
I have the following code that shows either a bug or a misunderstanding on
I have the following code that won't compile and although there is a way
I have the following code that sets a cookie: string locale = ((DropDownList)this.LoginUser.FindControl(locale)).SelectedValue; HttpCookie
I have the following code that creates two objects (ProfileManager and EmployerManager) where the
I have the following code that I need to add an additonal object to
I have the following JQuery code that worked perfect in C#/Asp.net 2.0 to call
I have the following html.erb code that I'm looking to move to Haml: <span
I have the following snippet of code that's generating the Use new keyword if
I have several blocks of the following code that each use there own matrix.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.