Nachiket Posted November 28, 2007 Posted November 28, 2007 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
amfony Posted December 3, 2007 Posted December 3, 2007 hello friend! I have the exsact same problem - please let me knw if u fixed this. Thanks
tunaroll Posted December 3, 2007 Posted December 3, 2007 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 recordsPls 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 installationNot 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now