me,myself,english and programming..

AutoIT – Connecting to SQL Server.

Playing around with AutoIt take me to next level of coding. :) This time I need to automate a process where in a normal situation it will involve a few people to make the whole process completed.

One of the process need a connection to MS-SQL ,execute query and and get the results. As sharing is caring, here I share how to connect to SQL-Server using AutoIt.

$conn = ObjCreate( "ADODB.Connection" )
$DSN = "DRIVER={SQL Server};SERVER=MySvr;DATABASE=MyDB;UID=MyUser;PWD=MyPwd;"
$conn.Open($DSN)
$rs = ObjCreate( "ADODB.RecordSet" )
$rs.Open( "SELECT @@VERSION AS myVersion", $conn )
MsgBox(0, "AutoIT-SQL Result", "Value = " & $rs.Fields( "myVersion" ).Value )
$conn.close

The code will produce a msg box like below.

autoIT SQL Result

Here you go…it’s only the basic code. You can do a lot more than this. :)

Have a nice weekend.

p/s: I have a job to do this weekend…..so..not a very nice weeked for me.adoii….

  1. 6 Responses to “AutoIT – Connecting to SQL Server.”

  2. By Halim-Belajar SEO on Jul 21, 2008 | Reply

    I once used autoit for making a bot for angels online but its quite so I stop. Autoit is quite good if you know programming and definitely not for me douh..

    Halim-Belajar SEO’s last blog post..Using GoDaddy for domain registration.

  3. By arejae on Jul 22, 2008 | Reply

    yeah…need to know at least a little bit programming.

    spammer also like this kind of automate tools. :)

  4. By Sarfraz Shah on Oct 17, 2008 | Reply

    Thanks :)

  5. By admin on Apr 5, 2010 | Reply

    Hi Scary, read my post here.
    http://www.arejae.com/blogv2/error-handling-in-autoit.html

  1. 2 Trackback(s)

  2. Feb 18, 2009: AutoIT - Connecting to Oracle. | Arejae.Com
  3. Apr 5, 2010: Arejae.Com » Blog Archive » Error handling in AutoIt

Post a Comment