PowerBuilder Connect MS-Access Database Using ODBC
Step 1: Driver ODBC MS-Access Database. Normally, if you connect to the .mdb extension, the driver is available in the window (Microsoft Access Driver (* .mdb)). If you connect to the .accdb(Microsoft Access Driver (*.mdb, *.accdb)) extension from office 2007 or later, you can download it on the mirosoft home page: https://www.microsoft.com/en-us/download/details.aspx?id=13255
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 | String ls_db, ls_database, ls_user, ls_pass, ls_odbcjt32 If wf_GetOSBits() = 64 Then // check windown 32/64 bit ls_odbcjt32 = "C:\Windows\SysWOW64\odbcjt32.dll" Else ls_odbcjt32 = "C:\Windows\System32\odbcjt32.dll" End If ls_user = "admin" ls_pass = "pass" ls_database = "database file .mdb or .accdb" If upper(right(trim(ls_database), 4)) = ".MDB" Then ls_db = "PBMDB" RegistrySet("HKEY_CURRENT_USE\Software\ODBC\ODBC.INI\"+ls_db,"DBQ",RegString!,ls_database) RegistrySet("HKEY_CURRENT_USE\Software\ODBC\ODBC.INI\"+ls_db,"Driver",RegString!,ls_odbcjt32) RegistrySet("HKEY_CURRENT_USE\Software\ODBC\ODBC.INI\"+ls_db,"DriverId",RegString!,"19") RegistrySet("HKEY_CURRENT_USE\Software\ODBC\ODBC.INI\"+ls_db,"FIL",RegString!,"MS Access;") RegistrySet("HKEY_CURRENT_USER\SOFTWARE\ODBC\ODBC.INI\ODBC DATA SOURCES",ls_db, RegString!, "Microsoft Access Driver (*.mdb)") Else ls_odbcjt32 = "C:\Program Files\Common Files\microsoft shared\OFFICE14\ACEODBC.DLL" ls_db = "PBACCDB" RegistrySet("HKEY_CURRENT_USE\Software\ODBC\ODBC.INI\"+ls_db,"DBQ",RegString!,ls_database) RegistrySet("HKEY_CURRENT_USE\Software\ODBC\ODBC.INI\"+ls_db,"Driver",RegString!,ls_odbcjt32) RegistrySet("HKEY_CURRENT_USE\Software\ODBC\ODBC.INI\"+ls_db,"DriverId",ReguLong!,25) RegistrySet("HKEY_CURRENT_USE\Software\ODBC\ODBC.INI\"+ls_db,"FIL",RegString!,"MS Access;") RegistrySet("HKEY_CURRENT_USER\SOFTWARE\ODBC\ODBC.INI\ODBC DATA SOURCES",ls_db, RegString!, "Microsoft Access Driver (*.mdb, *.accdb)") End if Transaction ltran_conn ltran_conn = Create Transaction // Using ODBC Connect To MS Access 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!
Touche. Outstanding arguments. Keep up the great effort.