Author Topic: Connecting to MySQL with v7  (Read 2877 times)

trollberry

  • Newbie
  • *
  • Posts: 2
Connecting to MySQL with v7
« on: April 28, 2007, 05:17:45 PM »
For those who wish to connect to a MySQL database from IceChat here's how (using VB).

1. Download the MySQL ODBC Driver from MySQL.
(and install it :P )

2. Set up a new ODBC database under Administrative Tools (Control Panel -> Administrative Tools).  Here you choose the MySQL driver and enter a name for the database, the user name that you set up to access the database etc.

3. Now for the IceChat bit:
Create a new test sub -
Code: [Select]
sub TestDatabase()
    set myconn = createobject("adodb.connection")
    connection = "driver={MySQL ODBC 3.51 Driver};server=localhost;user=[myuser];database=[mydatabase];"
    myconn.open (connection)
    set result = createobject("adodb.recordset")
    sql = "SELECT * FROM [mytable]"
    set result = myconn.execute(sql)
    if not result.EOF then
        sendcommand "/msg $active " & result(["a field name in table"])
    end if
end sub