Sign in to follow this  
Followers 0
diikee

SQL server database connection/access

11 posts in this topic

$db = ObjCreate("ADODB.Connection")
$db.Open("DSN=testing")

$dbdata = $db.Execute("SELECT * FROM testing")

dsn= testing --->>which contains the username, pswd, db

I get this error

C:\autoit\vmc.au3 (43) : ==> The requested action with this object has failed.:

$db.Open("DSN=testing")

$db.Open("DSN=testing")^ ERROR

Read through the search forums but no SQL server related material

Share this post


Link to post
Share on other sites



#4 ·  Posted (edited)

$con = _SQLStartup()
If @error then Msgbox(0,"Error","Error starting ADODB.Connection")
    
_SQLConnect(-1,"localhost","testing","d","dm")
if @Error then Msgbox(0,"",$SQLErr)
_SQLExecute(-1, "CREATE TABLE tstlog (Date_Time_Unit VARCHAR(20) UNIQUE,Test_Type VARCHAR(20),Status VARCHAR(10));")
if @Error then Msgbox(0,"",$SQLErr)
_SQLExecute(-1,"INSERT INTO tstlog (Date_Time_Unit,Test_Type,Status) VALUES ('"& @YEAR & "','"& @MON & "','"& @MDAY & "');")
if @Error then Msgbox(0,"",$SQLErr)

Connection and writing to the database works fine but i keep getting this errors....

--> IE.au3 V2.4-0 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)

--> IE.au3 V2.4-0 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)

--> IE.au3 V2.4-0 Warning from function _IELoadWait, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)

--> IE.au3 V2.4-0 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)

Edited by diikee

Share this post


Link to post
Share on other sites

$con = _SQLStartup()
If @error then Msgbox(0,"Error","Error starting ADODB.Connection")
    
_SQLConnect(-1,"localhost","testing","d","dm")
if @Error then Msgbox(0,"",$SQLErr)
_SQLExecute(-1, "CREATE TABLE tstlog (Date_Time_Unit VARCHAR(20) UNIQUE,Test_Type VARCHAR(20),Status VARCHAR(10));")
if @Error then Msgbox(0,"",$SQLErr)
_SQLExecute(-1,"INSERT INTO tstlog (Date_Time_Unit,Test_Type,Status) VALUES ('"& @YEAR & "','"& @MON & "','"& @MDAY & "');")
if @Error then Msgbox(0,"",$SQLErr)

Connection and writing to the database works fine but i keep getting this errors....

--> IE.au3 V2.4-0 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)

--> IE.au3 V2.4-0 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)

--> IE.au3 V2.4-0 Warning from function _IELoadWait, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)

--> IE.au3 V2.4-0 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)

Those errors have nothing to do with the code you posted.

They are errors from the IE include: you must calling some IE functions elsewhere in your script.

Show us that code...

Share this post


Link to post
Share on other sites

$con = _SQLStartup()
If @error then Msgbox(0,"Error","Error starting ADODB.Connection")
    
_SQLConnect(-1,"localhost","testing","d","dm")
if @Error then Msgbox(0,"",$SQLErr)
_SQLExecute(-1, "CREATE TABLE tstlog (Date_Time_Unit VARCHAR(20) UNIQUE,Test_Type VARCHAR(20),Status VARCHAR(10));")
if @Error then Msgbox(0,"",$SQLErr)
_SQLExecute(-1,"INSERT INTO tstlog (Date_Time_Unit,Test_Type,Status) VALUES ('"& @YEAR & "','"& @MON & "','"& @MDAY & "');")
if @Error then Msgbox(0,"",$SQLErr)

Connection and writing to the database works fine but i keep getting this errors....

--> IE.au3 V2.4-0 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)

--> IE.au3 V2.4-0 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)

--> IE.au3 V2.4-0 Warning from function _IELoadWait, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)

--> IE.au3 V2.4-0 Warning from function internal function __IEIsObjType, Cannot register internal error handler, cannot trap COM errors (Use _IEErrorHandlerRegister() to register a user error handler)

If your using my UDF for SQL then it has a Autoit.Error object registered so if you try to use ie as well it moans at you about not being able to register the ie error handler. However because I have already registered one in my UDF the ie errors wont make your script bomb out anyway

Share this post


Link to post
Share on other sites

ChrisL,

Yes, your explanation is correct since my script still executes fine. If I run your script without _ie function call, everything is sweet and clean.

Any work been done to clean those errors in the future??

Share this post


Link to post
Share on other sites

ChrisL,

Yes, your explanation is correct since my script still executes fine. If I run your script without _ie function call, everything is sweet and clean.

Any work been done to clean those errors in the future??

If you want to then lookin my UDF and comment out the line where I set the AutoIt.Error handler "Global $objErr = ObjEvent("AutoIt.Error","MyErrFunc")" and then call the IE one instead, you wont be able to check my $SQLErr for information on incorrect syntax or other errors though

Share this post


Link to post
Share on other sites

ChrisL,

Yes, your explanation is correct since my script still executes fine. If I run your script without _ie function call, everything is sweet and clean.

Any work been done to clean those errors in the future??

New version of the script has been uploaded here

The error handler is now optional and the _SQLGetData2D() function has been improved

Share this post


Link to post
Share on other sites

Tried it and got the following error

C:\Program Files\AutoIt3\Include\_sql.au3 (65) : ==> The requested action with this object has failed.:

$ret = $ConHandle.Execute ( $query )

$ret = $ConHandle.Execute ( $query )^ ERROR

Share this post


Link to post
Share on other sites

Tried it and got the following error

C:\Program Files\AutoIt3\Include\_sql.au3 (65) : ==> The requested action with this object has failed.:

$ret = $ConHandle.Execute ( $query )

$ret = $ConHandle.Execute ( $query )^ ERROR

Your not using any error handler and have passed some incorrect data and it crashed, so either use my error handler or the ie one

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  
Followers 0