PowerBuilder Connect SQLServer Using ODBC
Step 1: Install Driver ODBC SQLServer From Microsoft.com
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 | String ls_db, ls_database, ls_servername, ls_port, ls_user, ls_pass Boolean lb_reg ls_user = "User" ls_pass = "Password" ls_database = "database" ls_servername = "servername.com" ls_port = "port" ls_db = "PBSQLSERVER" Transaction ltran_conn ltran_conn = Create Transaction Disconnect Using ltran_conn ; If lb_reg Then //set database Transaction.database or odbc Database //RegistrySet("HKEY_CURRENT_USE\Software\ODBC\ODBC.INI\"+ls_db,"Database",RegString!,ls_database) RegistrySet("HKEY_CURRENT_USE\Software\ODBC\ODBC.INI\"+ls_db,"Server",RegString!,ls_servername + "," + ls_port) RegistrySet("HKEY_CURRENT_USE\Software\ODBC\ODBC.INI\"+ls_db,"Driver",RegString!,"sqlsrv32.dll") RegistrySet("HKEY_CURRENT_USE\Software\ODBC\ODBC.INI\ODBC DATA SOURCES",ls_db, RegString!, "SQL Server") ltran_conn.DBParm = "ConnectString='DSN="+ls_db+";UID="+ls_user+";PWD="+ls_pass+"'" Else ltran_conn.DBParm = "ConnectString='Driver={SQL Server};UID="+ls_user+";PWD="+ ls_pass +";SERVER=" + ls_servername + "," + ls_port +";'" //+ ";Database="+ls_database End If // Using ODBC Connect To SQLServer ltran_conn.DBMS = "ODBC" ltran_conn.AutoCommit = False ltran_conn.Database = ls_database Connect Using ltran_conn ; If ltran_conn.SQLCode = -1 Then MessageBox('Warning','Connect Database Error' + ltran_conn.SQLErrText) //HALT CLOSE Else MessageBox('Warning',"Connect Success!") End If Disconnect Using ltran_conn ; |
Find Projects On Github click here
Good Luck!