+ Reply to Thread
Results 1 to 15 of 15

ADO Error While Executing Command To Recordset

  1. #1
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,879

    ADO Error While Executing Command To Recordset

    Hi,

    On the line

    Set RS = Cmd.Execute

    I get this error

    Capture.GIF

    Can anyone tell me what might be wrong..

    Here is the full code -

    Please Login or Register  to view this content.
    Last edited by NeedForExcel; 09-11-2015 at 05:58 AM.
    Cheers!
    Deep Dave

  2. #2
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    England
    MS-Off Ver
    365, varying versions/builds
    Posts
    22,015

    Re: ADO Error While Executing Command To Recordset

    This is almost certainly an issue with your SP, not VBA or ADO. See for example: http://stackoverflow.com/questions/2...begin-and-comm
    Everyone who confuses correlation and causation ends up dead.

  3. #3
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,879

    Re: ADO Error While Executing Command To Recordset

    But If I copy values from the Parameters in Excel and Run it in the stored proc directly using SSMS, it works just fine..

  4. #4
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: ADO Error While Executing Command To Recordset

    Post the SQL you are using to Execute the SP in SSMS

  5. #5
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,879

    Re: ADO Error While Executing Command To Recordset

    Do you want the Stored Proc?

  6. #6
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: ADO Error While Executing Command To Recordset

    Not initially, I want to see how you're calling it in a way that works

  7. #7
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,879

    Re: ADO Error While Executing Command To Recordset

    Here is the piece of code that executes the SP

    Please Login or Register  to view this content.

  8. #8
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: ADO Error While Executing Command To Recordset

    Quote Originally Posted by NeedForExcel View Post
    If I copy values from the Parameters in Excel and Run it in the stored proc directly using SSMS, it works just fine..
    I want to see how you are doing this in SSMS (forget VBA for now)

    Something like:
    Please Login or Register  to view this content.

  9. #9
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,879

    Re: ADO Error While Executing Command To Recordset

    Oh Sorry..

    I go to the Object Explorer > Find the stored Proc > Right Click On the SP Name > Input the Parameters > Execute

  10. #10
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,879

    Re: ADO Error While Executing Command To Recordset

    On issue which I found is,

    Set RS = Cmd.Execute line should be Cmd.Execute.

    As there is no recordset, the SP just affects certain rows, and there another Select statement that returns data..

  11. #11
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: ADO Error While Executing Command To Recordset

    The problem is the sproc. Again, please post the SQL that works in calling the sproc, calling it through the gui, generates sql in a new window, please post it

  12. #12
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,879

    Re: ADO Error While Executing Command To Recordset

    Even when I directly do it, it still runs.. (Shortened Version Of the XML)

    EXEC DB_Common..SPName '<PType>VANILLA</PType><Solve>PREMIUM</Solve>', 'Bank1';
    Attached Images Attached Images

  13. #13
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: ADO Error While Executing Command To Recordset

    And what do you get if you execute that as a string? I.E

    Please Login or Register  to view this content.

  14. #14
    Forum Expert NeedForExcel's Avatar
    Join Date
    03-16-2013
    Location
    Pune, India
    MS-Off Ver
    Excel 2016:2019, MS 365
    Posts
    3,879

    Re: ADO Error While Executing Command To Recordset

    Hi,

    I found out the issue. It was my fault, the 2nd parameter was generating incorrectly..

    I am extremely sorry for wasting your time..

    Marking the thread as solved..

  15. #15
    Forum Guru Kyle123's Avatar
    Join Date
    03-10-2010
    Location
    Leeds
    MS-Off Ver
    365 Win 11
    Posts
    7,239

    Re: ADO Error While Executing Command To Recordset

    Glad you got it sorted

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [SOLVED] Executing Command Prompt commands through VBA
    By ndw123 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 08-25-2015, 12:17 PM
  2. [SOLVED] Run-time error '1004' when executing Exit Sub command line
    By Henk Stander in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 08-29-2014, 02:50 AM
  3. [SOLVED] Error in Executing the Command Button Action
    By Edelweiss in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-21-2012, 07:27 AM
  4. Executing a command button from a cell
    By grumpyguppy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 11-16-2010, 05:50 AM
  5. Executing the delete command in a macro
    By punter in forum Excel General
    Replies: 1
    Last Post: 11-16-2006, 03:45 PM
  6. Error when executing 'Charts.Add' command
    By vbaprog in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-15-2005, 03:05 PM
  7. [SOLVED] Perform SQL command on Disconnected ADO Recordset
    By R Avery in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 05-18-2005, 10:06 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1