Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
mysql QM connect
#5
This is example for mysql. Connects to local MySQL server as user 'root' (it is default user), password 'p' (you set it in MySQL server instance config wizard), and selects initial database 'menagerie'. Then shows contents of table 'pet'.

Macro
Code:
Copy      Help
Database db.Open("DRIVER={MySQL ODBC 5.1 Driver};DATABASE=menagerie;USER=root;PASSWORD=xxxx;")
ARRAY(str) a; int r c
db.QueryArr("SELECT * FROM pet" a)
for r 0 a.len(2)
,out "-- Record %i --" r+1
,for c 0 a.len(1)
,,out a[c r]

You need Connector/ODBC - MySQL ODBC driver.

http://dev.mysql.com/downloads/

If you have driver version 3.51, replace 5.1 to 3.51.


To connect to a remote database (if the web server allows it and you know all the parameters) can be used code like this:
Macro
Code:
Copy      Help
Database db.Open("Driver={MySQL ODBC 5.1 Driver};Server=db1.database.com;Port=3306;Option=131072;Database=mydb;Uid=myUsername;Pwd=myPassword")


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)