PowerBuilder Connect MySQL Using ODBC
Step 1: Get driver ODBC MySQL myodbc8w.dll MySQL ODBC 8.0 Unicode Driver or MySQL ODBC 8.0 ANSI Driver myodbc8a.dll from page : https://dev.mysql.com/downloads/connector/odbc/ or https://www.mysql.com/products/connector/
Step 2: Registry Regedit With Run file .Reg or PowerBuilder Function RegistrySet()
Step 3: Test Connect
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 |
String ls_db, ls_database, ls_servername, ls_port, ls_user, ls_pass String ls_ignore_space Boolean lb_Unicode, lb_ignore_space lb_Unicode = true ls_ignore_space = true ls_user = "user" ls_pass = "password" ls_database = "database" ls_servername = "server.com" ls_port = "port" If lb_ignore_space Then ls_ignore_space = "1" Else ls_ignore_space = "0" End If ls_db = "PBMYSQL" RegistrySet("HKEY_CURRENT_USE\Software\ODBC\ODBC.INI\"+ls_db, "AutoStop", RegString!, 'yes') RegistrySet("HKEY_CURRENT_USE\Software\ODBC\ODBC.INI\"+ls_db,"Database",RegString!,ls_database) RegistrySet("HKEY_CURRENT_USE\Software\ODBC\ODBC.INI\"+ls_db,"ServerName",RegString!,ls_servername) RegistrySet("HKEY_CURRENT_USE\Software\ODBC\ODBC.INI\"+ls_db,"Port",RegString!,ls_port) RegistrySet("HKEY_CURRENT_USE\Software\ODBC\ODBC.INI\"+ls_db,"IGNORE_SPACE",RegString!,ls_ignore_space) If lb_Unicode Then RegistrySet("HKEY_CURRENT_USE\Software\ODBC\ODBC.INI\"+ls_db,"Driver",RegString!,'myodbc8w.dll') RegistrySet("HKEY_CURRENT_USE\Software\ODBC\ODBC.INI\ODBC DATA SOURCES",ls_db, RegString!, "MySQL ODBC 8.0 Unicode Driver") Else RegistrySet("HKEY_CURRENT_USE\Software\ODBC\ODBC.INI\"+ls_db,"Driver",RegString!,'myodbc8a.dll') RegistrySet("HKEY_CURRENT_USE\Software\ODBC\ODBC.INI\ODBC DATA SOURCES",ls_db, RegString!, "MySQL ODBC 8.0 ANSI Driver") End If Transaction ltran_conn ltran_conn = Create Transaction // Using ODBC Connect To MySQL ltran_conn.DBMS = "ODBC" ltran_conn.AutoCommit = False ltran_conn.DBParm = "ConnectString='DSN="+ls_db+";UID="+ls_user+";PWD="+ls_pass+"'" Connect Using ltran_conn ; If ltran_conn.SQLCode = -1 Then MessageBox('Warning','Connect Database Error' + ltran_conn.SQLErrText) Else MessageBox('Warning',"Connect Success!") End If Disconnect Using ltran_conn ; |
Find Projects On Github click here
Good Luck!
Subscribe
Login
0 Comments
Oldest