Jump to content

Recommended Posts

Posted

Hello,

First of all, thanks you all for the help i have found on this forum through years.

 

Here is my issue :

I would like (through Autoit) to connect a MS SQL DB and execute a stored procedure wich is called "Test".

This procedure waits for no any argument.

From now i already can :

-Connect to the DB.

-Query it.

 

Here is the code i am using :

_SQLquery()

Func _SQLquery()
   $SQLinfo="DRIVER={SQL Server};SERVER=HOST_IP;DATABASE=DB_NAME;uid=USER_ID;pwd=USER_PW"
   $adCN = ObjCreate ("ADODB.Connection")
   $adCN.Open ($SQLinfo)
   $adCN.CommandType = 4
   $sQuery = "EXEC Test"
   $result = $adCN.Execute($sQuery)
   $adCN.Close
EndFunc

And i am getting the following error :

==> The requested action with this object has failed.:
$result = $adCN.Execute($sQuery)
$result = $adCN^ ERROR

 

I have tried many way to achieve my will (as using different UDF to connect to an SQL server to execute a stored procedure) and i am still getting the previous error message.

 

I would realy appreciate some help.

Thanks you

Posted

Take a look in my ADO.au3 UDF and examples in support topic. 

There was discussion on how to use stored procedure.

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

Posted

I managed to make it works.

For those who want to execute MS SQL stored procedure via Autoit, please take into consideration the above answer message from mLipok about ADO.au3 UDF and the first code exemple from the topic.

Don't forget to give your SQL access account the privilege to realise what you want it to do through the procedure (writing, reading, ..).

Also if you are blocked at the connexion step, take a look on your port forwarding (SQL), ODBCs and firewall authorisations.

 

At least, Thanks you mLipok.

 

Posted

I'm glad that my answer help you so much :)

 

Signature beginning:
Please remember: "AutoIt"..... *  Wondering who uses AutoIt and what it can be used for ? * Forum Rules *
ADO.au3 UDF * POP3.au3 UDF * XML.au3 UDF * IE on Windows 11 * How to ask ChatGPT for AutoIt Codefor other useful stuff click the following button:

  Reveal hidden contents

Signature last update: 2023-04-24

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...