20.35

Membuat Koneksi Powerbuilder ke Database SQLITE

Singkat saja, dalam tulisan ini saya mencoba membuat koneksi POWERBUILDER ke database SQLITE, berikut script yang ditulis didalam event open :

//===============================================
string ls_dbparm, ls_dbfile, ls_exepath, ls_file[]

ls_dbfile = 'sqlite_db_test.db3'

IF Fileexists(ls_dbfile) THEN
    // do nothing
ELSE
    IF GetFileOpenName('Select Data File',ls_dbfile, ls_file,'db3','SQLite files (*.db3),*.db3') < 1 THEN
        Messagebox('No Data File Chosen','Application will close')
        HALT CLOSE
    END IF
END IF
// SQLite connection
ls_dbparm = "ConnectString='"
// Driver installed with SQLite2009 Pro Enterprise Manager
ls_dbparm = ls_dbparm + "DRIVER=SQLite3 ODBC Driver;"
ls_dbparm = ls_dbparm + "Database=" + ls_dbfile + "'"
ls_dbparm = ls_dbparm + "UID=" + "admin" + ";PWD="
ls_dbparm = ls_dbparm +  "'"
sqlca.DbParm=ls_dbparm

sqlca.DBMS = "ODBC"

CONNECT USING SQLCA;

IF sqlca.sqlcode <> 0 then
MessageBox('Connect', 'Transaction not connect..'+sqlca.sqlerrtext,stopsign!)
Return
End IF

//============================================
Sekian dulu tulisan saya, semoga bisa membantu

Terima Kasih.