Sign in to follow this  
Followers 0
Nachiket

Unsuccessful while connecting to MySQL

3 posts in this topic

I have written a sample code to create a table in database named mysql. Also add a record in the same table. MySQL is installed on the same machine i.e developer machine on which I am working. Assuming that I have include mysql.au3 in the code. Following is the code that I have written. I have installed MySQL ODBC Driver version 5.1 on the same machine.

$sql = _MySQLConnect("root","ganesh","mysql","localhost")

MsgBox(0,"Connection Sucessful",$sql)

_CreateTable($sql, 'testtable', 'tt_id')

$var=_CreateTable($sql, 'testtable', 'tt_id')

MsgBox(0,"Connection Sucessful",$var)

_AddRecord($sql, 'testtable', 'tt_id', 1)

$count = _CountRecords($sql, 'testtable', 'tt_id', 1)

;this executes the query "SELECT * FROM `testtable` WHERE `tt_id` = 1 then counts the records

Pls let me know as to what changes I have to make. Also let me know if I have to make some changes in the registry post driver installation

Share this post


Link to post
Share on other sites



hello friend!

I have the exsact same problem - please let me knw if u fixed this.

Thanks

Share this post


Link to post
Share on other sites

I have written a sample code to create a table in database named mysql. Also add a record in the same table. MySQL is installed on the same machine i.e developer machine on which I am working. Assuming that I have include mysql.au3 in the code. Following is the code that I have written. I have installed MySQL ODBC Driver version 5.1 on the same machine.

$sql = _MySQLConnect("root","ganesh","mysql","localhost")

MsgBox(0,"Connection Sucessful",$sql)

_CreateTable($sql, 'testtable', 'tt_id')

$var=_CreateTable($sql, 'testtable', 'tt_id')

MsgBox(0,"Connection Sucessful",$var)

_AddRecord($sql, 'testtable', 'tt_id', 1)

$count = _CountRecords($sql, 'testtable', 'tt_id', 1)

;this executes the query "SELECT * FROM `testtable` WHERE `tt_id` = 1 then counts the records

Pls let me know as to what changes I have to make. Also let me know if I have to make some changes in the registry post driver installation

Not sure if this helps but I use this code block a lot in MS Access.

Be sure to test your query in phpMyAdmin or somehow then double check the syntax.

(In Access the sql syntax is not quite compatible with standard sql ie Access uses * for wildcard which must be changed to #)

$oConn = ObjCreate("ADODB.Connection")

$oRS = ObjCreate("ADODB.Recordset")

$oConn.Open($ConnStrg) ; $ConnStrg variable to hold your particular connection string

$oRS.Open($Query1, $oConn, 1, 3) ; $Query1 variable holds the query that you have written

$count = $oRS.RecordCount ; $count variable will now hold the record count.

good luck

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