Run SQL Stored Procedure from VBA

  • I have a SQL Stored Procedure in SQL Server 2012.
    I am trying to run the same from VBA but getting error.
    Here is my code.

    Code
    1. StoredProcedure = "CPSRM"
    2. con.Open constring
    3. cmd.ActiveConnection = con
    4. cmd.CommandTimeout = 0
    5. cmd.CommandText = StoredProcedure
    6. QRY = "EXEC CPSRMAIL"
    7. cmd.CommandType = adCmdText
    8. gg = cmd.Execute


    I am getting error run-time error '-2147467259 (80004005)'
    2013-06-20


    Pl let me know what am I missing.


    Regards,
    Spareus

  • Re: Run SQL Stored Procedure from VBA


    Your code is more than a little confusing, so perhaps an example might be best.


  • Re: Run SQL Stored Procedure from VBA


    Here it is as required by you.


    Thanks for reply.
    Regards.
    Spareus

  • Re: Run SQL Stored Procedure from VBA


    Please do not post questions in threads started by other members. Start your own thread, give it an accurate and concise title that summarises your issue and explain your problem fully, including any error messages shown.


    If you think this, or any other thread can help clarify your issue, you can include a link to it by copying the URL from the address bar of your browser when viewing the thread and pasting into your message.