// -------
// ------- usage :doubleclicked objek picture to add, change & update
// ------- thanks to original writer :tropicalbloom -------
integer fh, ret
string txtname, named
string defext = "JPG"
string Filter = "Jpeg Files (*.jpg), *.jpg"
integer li_FileNum, loops, i
long flen, bytes_read, new_pos
blob b, tot_b
string ls_curdir
ulong l_buf
l_buf = 100
ls_curdir = space(l_buf)
ls_curdir = GetCurrentDirectory( )
// Open File directory
ret = GetFileOpenName("Open Jpeg", txtname, named, defext, filter)
// select desired file to DataType BLOB gambar_sf
// Set a wait cursor
SetPointer(HourGlass!)
// Get the file length, and open the file
flen = FileLength(txtname)
li_FileNum = FileOpen(txtname, StreamMode!, Read!, LockRead!)
// Determine how many times to call FileRead
IF flen > 32765 THEN
IF Mod(flen, 32765) = 0 THEN
loops = flen/32765
ELSE
loops = (flen/32765) + 1
END IF
ELSE
loops = 1
END IF
// Read the file
new_pos = 1
FOR i = 1 to loops
bytes_read = FileRead(li_FileNum, b)
tot_b = tot_b + b
NEXT
FileClose(li_FileNum)
// blob gambar_sf ; Declare Instance Variables
gambar_sf = tot_b
p_1.SetPicture(gambar_sf)
//use updateblob to update into database
UPDATEBLOB pstaff SET pstaff.spic = :gambar_sf
WHERE pstaff.stafno = :ls_no_staf USING sqlca;
IF sqlca.SQLNRows > 0 THEN
messagebox('Updated', ls_no_staf)
COMMIT USING sqlca;
END IF
// returning to Default Directory"
ChangeDirectory (ls_dirname)
3 comments:
Thanks for post all about this PowerBuilder. Its Nice one.
be careful! UPDATEBLOB actually COMMITs itself immediately, along with anything else in your transaction!
Thanks for the info Nick.
Post a Comment