Jump to content

Recommended Posts

  • 2 months later...
  • Replies 385
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

here's the first release... only a few functions so far, any input would be appriciated Todo: _CreateTable() _CreateColumn() _DropCol() _DropTbl() _CountRecords() _CountTables() _GetTblNames() _GetCol

So much for homework lol... No includes, ready to compile and use wherever you like. Global Const $ES_PASSWORD = 32 Global Const $ES_AUTOVSCROLL = 64 Global Const $ES_AUTOHSCROLL = 128 $sDr

Try to use my ADO.au3 UDF - look in my signature.

Posted Images

Good afternoon,

I have been using this udf for a few months now and I am very pleased with it. I was using a my sql server hosted on my machine. But now I deployed the database to a remote server and I get the following error "[MySQL][OBDC 5.1 Driver] Unknown MySQL server host ' instance7146.db.xeround.com.:5528 ' (11004)". What do you think is the problem? That server address is working properly in the connection string of my php but not in autoit.

I've even tried adding an http:// to the server name but the result is the same.

The server is running mysql server version 5.1.42.

Is it possible that that host address cannot be resolved due to the dot right after the .com?

Any help would be appreciated. Thank you

[edit]

I don't think the problem is with my ODBC driver because the mysql server version on my localhost is 5.5.16-log so i'm assuming it's a more recent server version.

Edited by AtomR
Link to post
Share on other sites

I found the problem. It was my fault. I was using:

$sql = _MySQLConnect("xxx","xxx","xxx","instance7146.db.xeround.com.:5528")

I happened to look at the function signature in the udf and saw that there are other default values one of them is the port.

$sql = _MySQLConnect("xxx","xxx","xxx","instance7146.db.xeround.com.","{MySQL ODBC 5.1 Driver}",5528)

This is how it should have been all along. :oops:

Edited by AtomR
Link to post
Share on other sites
  • 1 month later...

get an array from SQL query

#cs
Function name: _Query2array
Description: Send a query to the database
Parameters: $oConnectionObj - As returned by _MySQLConnect. $sQuery - The query to execute
Return values: On success returns the query result by array. On failure returns 0 and sets @error to 1
Requirement(s):Autoit3 with COM support
Author: WayneHu
#ce
Func _Query2array($oConnectionObj,$sQuery)
$var = _Query($oConnectionObj,$sQuery)
If @error Then
  SetError(1)
  Return 0
EndIf

With $var
  $i = 0
  While Not .eof
   $i = $i + 1
   .movenext
  WEnd
EndWith

$var.movefirst

Dim $array[$i+1][$var.Fields.count+1]
$array[0][0] = $i
$array[0][1] = $var.Fields.count

For $r = 1 To $i
  For $c = 0 To $var.Fields.count-1
   $array[$r][$c+1] = $var.Fields($c).value
  Next
  $var.MoveNext
Next
Return $array
EndFunc

Example:

#include <mysql.au3>
#include <array.au3>
$conn = _MySQLConnect("root","","dbname","localhost")
;~ _Query($conn,"set names gb2312")
$var = _Query2array($conn,"SELECT * FROM table_name where userid=156")
_ArrayDisplay($var)
_MySQLEnd($conn)
Link to post
Share on other sites
  • 4 weeks later...

can anybody please help me, with :

==> Only Object-type variables allowed in a "With" statement.:

With $TableContents

With ^ ERROR

in this topic ===>

I did create another topic for my question. So please if anyone can help, post at that topic.

Edited by Siwa
Link to post
Share on other sites
  • 4 weeks later...

Solution Found: I installed the 32 bit version of mysql odbc - mysql-connector-odbc-5.1.11-win32.msi

and it's working just fine (i didn't uninstall the 64 version but don't believe it matters)

___

Hi,

I've been using this UDF for a long time now but upgraded to windows 7 64 bit and now can't connect to mysql.

to be more specific, even the RegRead doesn't work:

$v=MySQL ODBC 5.1 Driver
$key=HKEY_LOCAL_MACHINESOFTWAREODBCODBCINST.INIODBC Drivers
$val = RegRead($key, $v)

$val returns an empty string even-though I installed MYSQL ODBC 5.1 64bit driver and I see it in window's regedit:

Posted Image

and further-more,

if I ignore the RegRead,

and take it further to creating the connection:

$ObjConn = ObjCreate("ADODB.Connection")
traceLog("ObjCreate error="&@error)
$connString="DRIVER=" & $sDriver & ";SERVER=" & $sServer & ";DATABASE=" & $sDatabase & ";UID=" & $sUsername & ";PWD=" & $sPassword & ";PORT="&$iPort
traceLog("$connString="&$connString)
$Objconn.open ($connString)

where $connString is:

"DRIVER={MySQL ODBC 5.1 Driver};SERVER=xxx.org;DATABASE=xxx;UID=xxx;PWD=xxx;PORT=3306"

I see that the ObjCreate returns error=0 (so I assume it found the object) but I get this failure:

--> COM Error Encountered in social submitter.au3

----> $IEComErrorScriptline = 44

----> $IEComErrorNumberHex = 80020009

----> $IEComErrorNumber = -2147352567

----> $IEComErrorWinDescription = Unspecified error

----> $IEComErrorDescription = [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified

----> $IEComErrorSource = Microsoft OLE DB Provider for ODBC Drivers

----> $IEComErrorHelpFile =

----> $IEComErrorHelpContext = 0

----> $IEComErrorLastDllError = 0

Any help would much more appreciate, this code worked fine for me in my old laptop with XP so I'm afraid it's something to do with windows 7

or the driver I installed? the 64 bit one: mysql-connector-odbc-5.1.11-winx64.msi

Many Thanks!!

Edited by hagaizenberg
Link to post
Share on other sites
  • 3 weeks later...

Maybe this will help about registry

Win 7 x64

HKEY_LOCAL_MACHINESOFTWAREWow6432NodeODBCODBCINST.INIODBC Drivers

Win 7 x86

HKEY_LOCAL_MACHINESOFTWAREODBCODBCINST.INIODBC Drivers

Sorry, didn't try it....but it's a clue ;)

Edited by imbrija
Link to post
Share on other sites
  • 1 month later...

if input wrong $sUsername, $sPassword, $sDatabase, or $sServer this Exit

and e

C:UsersBao VietDesktopmysql.au3 (27) : ==> The requested action with this object has failed.:
$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
>Exit code: 1 Time: 6.468

how to run MsgBox when wrong ?

Edited by choidk
Link to post
Share on other sites
  • 1 month later...

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

AutoIt Error

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

Line 5 (File "C:UsersUserDesktopMySQLwork.au3"):

With $var

With ^ ERROR

Error: Only Object-type variables allowed in a "With" statement.

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

OK

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

Link to post
Share on other sites
  • 3 months later...

Hi fellow members,

This is a great UDF, I'm using it on some of my little application sucessfully - thanks to cdkid!

Currently I'm facing this problem: after a very short time (maybe around 60 secs) after connection is made, this error occured: "MySQL server has gone away".

I want it to connect when the application run at the first time and only disconnect when the user quit.

Is there anyway to initiated somekind of auto-connect or extend the timeout period to the maximum?

ODBC version is 3.5.1 running on Windows XP SP2

Thanks in advance :)

Link to post
Share on other sites
  • 3 weeks later...
  • 1 month later...
  • 7 months later...

Post a short reproducer example code here and you can expect help.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to post
Share on other sites

Hi jchd, 

 My code

$MYSQLUserName = "u_autoit"

    $MYSQLPassword = "123"
    $MYSQLDatabase = "autoit"
    $MySQLServerName = "localhost"
    Global $SQLQuery = _MySQLConnect($MYSQLUserName,$MYSQLPassword,$MYSQLDatabase,$MySQLServerName)
    $Result = _Query($SQLQuery,"SELECT name FROM information")
    If @error Then
        MsgBox(0, "Error SQL", "Error when executing SQL")
    Elseif IsObj($Result) Then
        With $Result
        While Not .EOF
            $data = .Fields ("name").value
            .MoveNext
        WEnd
        EndWith
    Else
        MsgBox(0, "SQL Error", "Something went wrong without error. Maybe no result ?")
    EndIf
                msgbox(0,'Hello', $name)

Field name in mysql contain data: 'Khát Vọng' but when the window msg show: Khát V?ng 

( If i get data in file .txt that's ok , just issue with use mysql ) :(

Edited by doinguyen
Link to post
Share on other sites

Which charset do you use for the column and are you positive that the specific row contains Unicode data (not Big5 or such MBCS charset)?

Can you display your DB schema?

Your best bet is to always use UTF8 with BOM AutoIt source files.

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

Link to post
Share on other sites

In your code excerpt, you load $data with the column result, but you display $name in the MsgBox.

It sounds like $name contained the same string have passed thru Unicode to ANSI conversion (hidden in some AutoIt functions).

Can you double check by running the following:

Local $MYSQLUserName = "u_autoit"
Local $MYSQLPassword = "123"
Local $MYSQLDatabase = "autoit"
Local $MySQLServerName = "localhost"
Local $Literal = 'Khát Vọng'
Local $SQLQuery = _MySQLConnect($MYSQLUserName, $MYSQLPassword, $MYSQLDatabase, $MySQLServerName)
Local $data
Local $Result = _Query($SQLQuery,"SELECT " & $Literal & as test;")
If @error Then
    MsgBox(0, "Error SQL", "Error when executing SQL")
Elseif IsObj($Result) Then
    With $Result
        While Not .EOF
            $data = .Fields("test").value
            .MoveNext
        WEnd
    EndWith
Else
    MsgBox(0, "SQL Error", "Something went wrong without error. Maybe no result ?")
EndIf
MsgBox(0, 'MySQL literal', $data)

MsgBox(0, 'AutoIt literal', $Literal)

This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.
Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe here
RegExp tutorial: enough to get started
PCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta.

SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.
SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.
An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.
SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)
A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!
SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt)

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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...