Jump to content

MySQL UDFs


cdkid
 Share

Recommended Posts

The requested action with this object has failed.:

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

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

the ^error is supposed to be pointing at the C on Objconn but it wouldnt work wit code or quote

i was just trying teh function too x . x

Edited by Bounda
Link to comment
Share on other sites

The requested action with this object has failed.:

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

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

the ^error is supposed to be pointing at the C on Objconn but it wouldnt work wit code or quote

i was just trying teh function too x . x

See my post on page 1 about error handling. Make sure you have the correct credentials, and are running your program under beta.

~cdkid

AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!
Link to comment
Share on other sites

  • 2 weeks later...
  • 2 weeks later...

I just started working on this and I can't get it to work. I've installed "MyODBC-3.51.10-2-win.msi" on my PC and MySQL 5.0.19.

Here's My code:

#include <MySQL.au3>
$mysql_srv = "10.10.81.65"

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

$sql = _MySQLConnect('tester','chc2006','domainquery',$mysql_srv)
MsgBox(64,"",$sql)
_CreateTable($sql, 'testtable3', 'tt_id')
_CreateTable($sql, 'testtable', 'tt_id')
_AddRecord($sql, 'MyField', 'tt_id', 1)
_MySQLEnd($sql)


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

Using your error control, it returns this:

Description: Catastrophic Failure

err.number is 80020009

err.source is: Provider

err.helpcontext is: 1240640

I've also tried using "mysql-connector-odbc-5.0.0-alpha-win32.msi" and modifying the MySQL.au3 to reflect the driver location. It doesn't error, but it won't write to the DB.

Public: 3.1.1.0

Beta: 3.1.1.123

Any help would greatly be appreciated!

Link to comment
Share on other sites

  • 1 month later...

Nice script. Just what I needed. So far it works great except for this

Global $db = _MySQLConnect("root","","table","localhost")

That will work just fine but if I were to change it to this

Global $db = _MySQLConnect("root","","table","192.168.1.176")

I get this error

The requested action with this object has failed.:

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

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

>AutoIT3.exe ended.

The others that had this error seemed to get it fixed by using the latest beta. But I do have the latest beta. I go the one that was released just a few days ago.

I have the ODBC Drivers installed. It seems to only work when set to localhost. I would like to use this on a LAN so I will need to use an IP address or the name of the PC acting as the server, which I tried that also and it didnt work.

The client machine I used also has the ODBC Drivers installed. And just to be sure it wasn't something wrong with the client machine I tried it on the server as well and got the same error.

Any ideas?

Edited by Marklar
Link to comment
Share on other sites

See the error handler on page 2 or 3 (can't remember which). It should tell you the problem.

~cdkid

AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!
Link to comment
Share on other sites

I'll check. I've been away so I haven't had time to check... Right now it's late so I'll update tommorow mornin.

AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!
Link to comment
Share on other sites

This is great. I been looking for somethig like this for a while. I'm trying "include" this UDF in one of my scripts, but I keep getting this message:

C:\Documents and Settings\........\Dev\v.0.1\MySQL.au3 (328) : ==> Unable to parse line.:

While Not .EOF

While Not .E^ ERROR

I've installed the ODBC drivers as outlined on your post, but still having problems. I've been using AutoIT for small projects, but nothing this in depth before. Please help. Thanks.....

Link to comment
Share on other sites

I am running a server from my computer, and I have mySQL5 installed on my computer. will installing that ODBC thing mess up my sql? do i even need to install it?

The cake is a lie.www.theguy0000.com is currentlyUP images.theguy0000.com is currentlyUP all other *.theguy0000.com sites are DOWN

Link to comment
Share on other sites

  • 4 weeks later...

Hello all,

I have written a program that uses your excellent UDF a few months ago. Today I needed to update something and when I tried to run or compiled it, AU3 came up with this error:

Only Object-type variables allowed in an "With" statement.:
With $query 
With ^ ERROR
+>AutoIT3.exe ended.rc:0
>Exit code: 0   Time: 1.423

I then remembered that I hadn't installed the MySQL ODBC driver on this computer. However, some time ago you have given me a trick to handle the COM errors:

$objErr = ObjEvent("AutoIt.Error","ErrorHandler"); COM error handler

Func ErrorHandler()
    $hexnum = Hex($objErr.number, 8)
    MsgBox(0, "title", $objErr.description & @CRLF & $objErr.windescription)
    Exit
EndFunc

...which with previous AU3 versions worked as a charm. Now it didn't. Can you think of a reason?

Of course after installing the MySQL ODBC drivers, my code (except of the COM error handler...) worked normally, so the $query is not wrong.

I'm using latest stable and latest beta (130).

Edited by erebus
Link to comment
Share on other sites

I am running a server from my computer, and I have mySQL5 installed on my computer. will installing that ODBC thing mess up my sql? do i even need to install it?

Install the ODBC 3.51 and you will have no problem at all. The driver is irrelevant to your MySQL installation on the same machine.

Link to comment
Share on other sites

  • 1 month later...

I have a test script where I am querying a table for username and displaying the results. If I query on a username that doesn't exist I want to be able to handle this...however, @error is set to 0 whether the query works or fails.

In my code below I display the error level as soon as the query is made so that I can troubleshoot. Am I misinterpreting the use of the @error macro? If enter a username that doesn't exist shouldn't the query fail and set @error to 1? Currently, it sets @error to a 0 either way.

Using AutoIt 3.2 and the latest MySQL.au3

Thanks,

Mike.

#include <GUIConstants.au3>
#include <String.au3>
#include <MySQL.au3>

; == GUI generated with Koda ==

Opt("TrayIconHide", 1)
Opt("GUICloseOnESC", 0)

$Form1 = GUICreate("SSB Credit Worksheet Login", 270, 142, 450, 271)

$Input1 = GUICtrlCreateInput("", 112, 24, 121, 24, -1, $WS_EX_CLIENTEDGE)
$Input2 = GUICtrlCreateInput("", 112, 56, 121, 24, $ES_PASSWORD, $WS_EX_CLIENTEDGE)

GUICtrlCreateLabel("Username:", 32, 24, 70, 24, $SS_CENTERIMAGE)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")
GUICtrlCreateLabel("Password:", 32, 56, 67, 24, $SS_CENTERIMAGE)
GUICtrlSetFont(-1, 10, 400, 0, "MS Sans Serif")

$Button1 = GUICtrlCreateButton("OK", 48, 104, 75, 25, $BS_DEFPUSHBUTTON)
$Button2 = GUICtrlCreateButton("Cancel", 152, 104, 75, 25)

$objErr = ObjEvent("AutoIt.Error","MyErrFunc")
        
$db = _MySQLConnect("tcadmin","s9o1u0t3","ssbcrw", "10.206.1.27")

GUISetState(@SW_SHOW)

While 1
    $msg = GuiGetMsg()
    Select
    Case $msg = $GUI_EVENT_CLOSE

        ExitLoop

    Case $msg = $Button1

        $user = GUICtrlRead($Input1)
        
        $var = _Query($db,"SELECT * FROM users WHERE username = '" & $user & "'")
        MsgBox(0,"Test - Error Level",@error)
            If @error Then
                MsgBox(0,"Test","That username is NOT found!")
                
            Else
        
                $authority = $var.Fields("fullname").value
                $password = $var.Fields("password").value
                MsgBox(0,"test","checkuser = " & $authority)
                MsgBox(0,"test","checkpass = " & $password)
                ExitLoop
            EndIf

    EndSelect
WEnd

_MySQLEnd($db)

Exit

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

Well, i have an idea.

Rather than selecting it that way, which removes any custom error handling u can use try using something like

Select username from `users`;

and then loop through there, checking it then if it's found

Select * From `users` WHERE username = w/e;

and then verify the password.

--Hope this helps

~cdkid

Edited by cdkid
AutoIt Console written in C#. Write au3 code right at the console :D_FileWriteToLineWrite to a specific line in a file.My UDF Libraries: MySQL UDF Library version 1.6 MySQL Database UDF's for AutoItI have stopped updating the MySQL thread above, all future updates will be on my SVN. The svn location is:kan2.sytes.net/publicsvn/mysqlnote: This will still be available, but due to my new job, and school hours, am no longer developing this udf.My business: www.hirethebrain.com Hire The Brain HireTheBrain.com Computer Consulting, Design, Assembly and RepairOh no! I've commited Scriptocide!
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...