Jump to content

SQL (M$) help please!


Recommended Posts

Hi.

AutoIt Version = 3.2.8.1

Have copied SQL.AU3 to the ...include directory.

SQL.AU3 Topic Link - http://www.autoitscript.com/forum/index.ph...&hl=sql.au3

Attempting to run the following code....

CODE
#include <sql.au3>

_SQLConnect ( 'server_name', 'db_name', 'user', 'password' )

_SQLExecute ( 'select OFFEREDDATETIME, callstatus from cid_t_VJcallinformation where offereddatetime > "2007-09-11 00:00:01"')

_SQLClose()

Getting the following error.....

CODE
>"C:\Program Files\SciTE\AutoIt3Wrapper\AutoIt3Wrapper.exe" /run /prod /ErrorStdOut /in "C:\Documents and Settings\petes\My Documents\sqltest.au3" /autoit3dir "C:\Program Files\AutoIt3" /UserParams

+> Starting AutoIt3Wrapper v.1.7.3

>Running AU3Check (1.54.9.0) params: from:C:\Program Files\AutoIt3

C:\PROGRA~1\AutoIt3\Include\sql.au3(14,36) : WARNING: $adCN: possibly used before declaration.

$adCN.Close ;==>Close the database

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\PROGRA~1\AutoIt3\Include\sql.au3(9,35) : WARNING: $adCN: declared global in function only. Prefer top of file.

Global $adCN ;<==Declare variable

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^

C:\Documents and Settings\petes\My Documents\sqltest.au3 - 0 error(s), 2 warning(s)

->AU3Check ended.rc:1

>Running:(3.2.8.1):C:\Program Files\AutoIt3\autoit3.exe "C:\Documents and Settings\petes\My Documents\sqltest.au3"

C:\PROGRA~1\AutoIt3\Include\sql.au3 (17) : ==> The requested action with this object has failed.:

$adCN.Execute ( $query )

$adCN.Execute ( $query )^ ERROR

->AutoIT3.exe ended.rc:1

>Exit code: 1 Time: 4.608

Can anyone help? I need to clear the error and then I need the two variables to be available for comparison.

Please note - I'm a Systems Tester, not a Developer, so please bear with me!

The AutoIt help file should be interrogated.The Editor should be SciTe.The forums should have been searched.

Link to comment
Share on other sites

Thanks. Made some progress.

1. in the SQL.AU3 include file, move the GLOBAL definition out of the function definitions, thus

CODE

Global $adCN ;<==Declare variable

Func _SQLConnect($server, $db, $username, $password)

$adCN = ObjCreate ("ADODB.Connection") ;<==Create SQL connection

$adCN.Open ("DRIVER={SQL Server};SERVER=" & $server & ";DATABASE=" & $db & ";uid=" & $username & ";pwd=" & $password & ";") ;<==Connect with required credentials

EndFunc

Func _SQLClose ()

$adCN.Close ;==>Close the database

EndFunc

Func _SQLExecute( $query )

$adCN.Execute ( $query )

EndFunc

2. Edit the Select statement to remove the double quotes, replaceing with two-singlw quotes, thus

_SQLExecute ( 'select OFFEREDDATETIME, callstatus from cid_t_VJcallinformation where offereddatetime > ''2007-09-11 00:00:01''')

(OK, I had some help!)

So now things run ok, but how do I get my data? where is it?

The AutoIt help file should be interrogated.The Editor should be SciTe.The forums should have been searched.

Link to comment
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
 Share

  • Recently Browsing   0 members

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