Pages

Tuesday, March 7, 2017

Powerbuilder with MySQL Database

One of the easiest way to connect to MySQL DB from Powerbuilder is thru ODBC connection. You have to install latest version of MySQL ODBC Driver  from their official site: https://dev.mysql.com/downloads/file/?id=415028 Download the 32 bits version


Once you downloaded and installed, you will found the MySQL ODBC driver on your ODBC Windows.



Create a User DSN profile to connect to your MySQL Database, put the Data Source Name, etc.



Ceate a new Database Profile in Powerbuilder Database Painter and link the data source into the User DSN. Put the Username and Password.



Select the Preview tab then click the Test Connection button to make sure that you can connect to your database.



As a powerscript, click the Copy button and put inside the event that you want to connect

  1. // Profile MySQL  
  2. SQLCA.DBMS = "ODBC"  
  3. SQLCA.AutoCommit = False  
  4. SQLCA.DBParm = "ConnectString='DSN=xxxxx;UID=xxxx;PWD=<******>'"  
  5.   
  6. CONNECT USING SQLCA;  


No comments:

Post a Comment