Jump to content
Sign in to follow this  

ADODB command method

Recommended Posts


I'm trying to run a SQL stored procedure that will take a long time.

I think if I can run the SP in async mode, it will work, but I'm having trouble getting the syntax right.

Here's a VBScript example of what I want to do:

Dim cmd As ADODB.Command

Set cmd = New ADODB.Command

cmd.ActiveConnection = "DSN = test"

cmd.CommandTimeout = 180

cmd.CommandText = "sp_name"

cmd.CommandType = adCmdStoredProc

cmd.Execute , , adAsyncExecute

Here is my AutoIT interpretation:

$adoCon = ObjCreate("ADODB.Connection")
        $adoCon.Open ($DSN)
        $objCommand = ObjCreate("ADODB.Command")
        $objCommand.ActiveConnection = $adoCon
        $objCommand.CommandTimeout = 10
        $objCommand.CommandText = "_init_img_tables" 
        $objCommand.CommandType = 4;(I got  the value "4" as the CommandTypeEnum Value for "adCmdStoredProc' from http://www.w3schools.com/ADO/prop_comm_commandtype.asp)
        $objCommand.Execute = ", 400, adAsyncExecute";(See http://www.w3schools.com/ADO/met_comm_execute.asp)

I want ..".execute , , adAsyncExecute" which means execute <no return value>,<parameter in is "400">,<with Option "adAsyncExecute">

the console output is:

C:\Program Files\autoit\test.au3 (324) : ==> The requested action with this object has failed.:

$objCommand.Execute = ", 400, adAsyncExecute"

$objCommand.Execute = ", 400, adAsyncExecute"^ ERROR

I can successfully use the "execute" method "Plain". But how do I use it with these options?

Thanks in advance,


Edited by bobneumann

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  


Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.