Export Excel sheet directly to MSSQL using script

  • Having a bit of trouble, I'm trying to take data in a sheet from SQL and send it to a MSSQL database using a script I've found some code that another user that was trying to do the same thing used (Located here: http://answers.microsoft.com/e…92-4950-8844-9e65f79c9850) and I have made adjustments so it can get to my server, but when I run it I either get:
    "An unexpected error occured
    Number: -2147217900 Desc: Could not find stored procedure 'dbo.headcountstest" or I get:
    "an unexpected error has occured
    Number: -2147217887 Desc: Multiple-step OLE DB operation generated errors. Check each OLE DB status value, if available. No work was done."


    When removing the rest and using a different script to test the connection, the connection says adOpen, which I assume mean everything is good.


    Here is the script I'm using:


    Any help is greatly appreciated.

  • Re: Export Excel sheet directly to MSSQL using script


    Hello ikith,


    I presume you checked the presence of the "headcountstest" stored procedure? This looks to be the first place to start. Make sure you haven't spelled it incorrectly, and remove the "dbo." from within your VBA.


    Hope this helps.

    Cheers,


    Matthew

  • Re: Export Excel sheet directly to MSSQL using script


    Next question...


    What does the procedure "headcountstest" do? To me it looks to return just a value!

  • Re: Export Excel sheet directly to MSSQL using script


    Hello Barry,


    If it's a stored procedure (as indicated by the OP), it will be a query (or SQL View) saved on the SQL server itself that returns a recordset. Without knowing more about the database or the stored procedure itself, I can't be clearer that that.


    Presumably the stored procedure doesn't have any parameters (variable fields or constraints) associated with it, as the OP has not appended these in the code.


    Hope this helps.

    Cheers,


    Matthew

  • Re: Export Excel sheet directly to MSSQL using script


    Yeah Matthew


    It could be a query that just returns a number as well. I mean a procedure named head counts test?????



    Agreed need way more information. The OP doesn't state if the procedure works within the DBase itself.

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!