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.

08.41

Konversi Hex Ke Binary

Kali ini saya ingin membuat beberapa FUNCTION untuk mengkonversi bilangan HEX ke dalam bentuk Binary secara sederhana

1. Buat New Function dengan function name "f_hex_to_bin"
2. Isi Return Type dengan "string"
3. Isi Argument Type dengan "string" dan Argument Name dengan "as_param_hex"
4. Tuliskan powerscript dibawah ini
5. Selamat mencoba...


integer i,li_length
string ls_param_hex,ls_hex,ls_binary,ls_huruf

ls_param_hex = trim(as_param_hex)

li_length = len(ls_param_hex)

for i = 1 to li_length

ls_huruf = Mid(ls_param_hex, i,1)

choose case ls_huruf
case '0'
ls_binary = '0000'
case '1'
ls_binary = '0001'
case '2'
ls_binary = '0010'
case '3'
ls_binary = '0011'
case '4'
ls_binary = '0100'
case '5'
ls_binary = '0101'
case '6'
ls_binary = '0110'
case '7'
ls_binary = '0111'
case '8'
ls_binary = '1000'
case '9'
ls_binary = '1001'
case 'A'
ls_binary = '1010'
case 'B'
ls_binary = '1011'
case 'C'
ls_binary = '1100'
case 'D'
ls_binary = '1101'
case 'E'
ls_binary = '1110'
case 'F'
ls_binary = '1111'
end choose

ls_hex = ls_hex + ls_binary

next

return ls_hex

Lain kali saya akan coba untuk membuat function2 yang semoga bisa bermanfaat untuk para penggemar PB.