Jump to content

Problem with connectin to MySQL server


Lack
 Share

Recommended Posts

Hey there,

I'm trying to connect to my MySQL using the MySQL UDF (http://www.autoitscript.com/forum/index.php?showtopic=20814) but I'm getting a constant error:

---------------------------
AutoIt Error
---------------------------
Line 0  (File "C:\Files\MySQL\test.exe"):

$Objconn.open ("DRIVER=" & $sDriver & ";SERVER=" & $sServer & ";DATABASE=" & $sDatabase & ";UID=" & $sUsername & ";PWD=" & $sPassword & ";PORT="&$iPort)
$Objconn.open ("DRIVER=" & $sDriver & ";SERVER=" & $sServer & ";DATABASE=" & $sDatabase & ";UID=" & $sUsername & ";PWD=" & $sPassword & ";PORT="&$iPort)^ ERROR

Error: The requested action with this object has failed.
---------------------------
OK   
---------------------------

I'm using just the basic code from mysql.au3 with the same function to test the connection only

$sql = _MySQLConnect("username","password","database_name","server_name")
_MySQLEnd($sql)

There must be a problem with the login procedure, but I've tried several different combination of the variable (server_name as name, ip address, localhost) and none worked.

I can connect to the database using the standard command prompt.

Any ideas what am I doing wrong?

Link to comment
Share on other sites

Test @error after the initial _MySqlConnect(). Don't go on until you get @error = 0 for the connect. If you get @error = 2, then your driver is the issue (see the header of the function in the UDF).

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

I'm trying the error checking script from: http://www.autoitscript.com/forum/index.ph...mp;#entry143887

---------------------------

---------------------------
We intercepted a COM Error!!



err.description is: unidenfited error

err.windescription is: unidenfited error



err.lastdllerror is: 0

err.scriptline is: 0

err.number is: 80020009

err.source is: Provider

err.helpfile is: 

err.helpcontext is: 1240640
---------------------------
OK   
---------------------------

My whole testing scrip looks like this:

$objErr = ObjEvent("AutoIt.Error","MyErrFunc")

#include "mysql.au3"

test()

Func test()
    $sql = _MySQLConnect("user","pass","test","localhost")
    _MySQLEnd($sql)
EndFunc

Func MyErrFunc()
    $hexnum=hex($objErr.number,8)
    Msgbox(0,"","We intercepted a COM Error!!"      & @CRLF                & @CRLF & _
             "err.description is: " & $objErr.description   & @CRLF & _
             "err.windescription is: " & $objErr.windescription & @CRLF & _
             "err.lastdllerror is: "   & $objErr.lastdllerror   & @CRLF & _
             "err.scriptline is: "   & $objErr.scriptline    & @CRLF & _
             "err.number is: "       & $hexnum               & @CRLF & _
             "err.source is: "       & $objErr.source        & @CRLF & _
             "err.helpfile is: "       & $objErr.helpfile      & @CRLF & _
             "err.helpcontext is: " & $objErr.helpcontext _
            )
    exit
EndFunc

I've found several people that had the same problem in the original UDF forum but no one posted a solution :).

Link to comment
Share on other sites

That catches COM errors, which is good, but might not be your (only) problem. Try this:

#include "mysql.au3"

$objErr = ObjEvent("AutoIt.Error","MyErrFunc")

Global $sql

test()

Func test()
    $sql = _MySQLConnect("user","pass","test","localhost")
    If @error Then
        MsgBox(16, "Error", "_MySQLConnect() failed, @error = " & @error)
        Exit
    EndIf
    _MySQLEnd($sql)
EndFunc

Func MyErrFunc()
    $hexnum=hex($objErr.number,8)
    Msgbox(0,"","We intercepted a COM Error!!"        & @CRLF                   & @CRLF & _
             "err.description is: "    & $objErr.description    & @CRLF & _
             "err.windescription is: " & $objErr.windescription & @CRLF & _
             "err.lastdllerror is: "   & $objErr.lastdllerror   & @CRLF & _
             "err.scriptline is: "     & $objErr.scriptline     & @CRLF & _
             "err.number is: "         & $hexnum                 & @CRLF & _
             "err.source is: "         & $objErr.source         & @CRLF & _
             "err.helpfile is: "       & $objErr.helpfile       & @CRLF & _
             "err.helpcontext is: "    & $objErr.helpcontext _
            )
    exit
EndFunc

:)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

That catches COM errors, which is good, but might not be your (only) problem. Try this:

I get the same error with this :).

It just always crashes on the $Objconn.open ("DRIVER=" & $sDriver & ";SERVER=" & $sServer & ";DATABASE=" & $sDatabase & ";UID=" & $sUsername & ";PWD=" & $sPassword & ";PORT="&$iPort)

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...