Home > database >  Pb how to access database in bulk storage (long binary format) picture?
Pb how to access database in bulk storage (long binary format) picture?

Time:10-20

This code the image has been batch stored in the access database, but the storage of the images are selected the first picture, such as: I pick the first 10 images, it is stored and 10 pictures, but is the first file, 2-10 is not stored images,
How to improve this code you help,
Note: the selected image name as well as database ID

String ls_photofile
Integer li_filenum, p_id, I
The integer li_loops
The integer li_counter
Blob lb_picture
Long ll_filelen
Blob ll_read
Long ll_num
String ls_pathname ls_filename []
The integer li_value

//1, a picture
Li_value=https://bbs.csdn.net/topics/GetFileOpenName (" choose photo ", & amp;
+ ls_pathname, ls_filename [], "image", "JPG File (*.jpg), * JPG, BMP File (*. BMP), *. BMP, GIF File (*. GIF), *. GIF")
IF li_value=https://bbs.csdn.net/topics/1 THEN
Elseif li_value=https://bbs.csdn.net/topics/-1 then
MessageBox (" choose photo ", "open the file error!" )
End the If

Ll_num=upperbound (ls_filename)

For I=1 to ll_num

//2, for the image binary data
//processing photos file data begin

Ls_photofile=ls_filename [I]
Ll_filelen=filelength (ls_photofile)
Li_filenum=fileopen (ls_photofile streammode! , read! , lockread!)

If ll_filelen & gt; Then 32765
Li_loops=((ll_filelen - 1)/32765) + 1
The else
Li_loops=1
End the if
?
//read the file
For li_counter=1 to li_loops
Fileread (li_filenum ll_read)
Lb_picture=lb_picture + ll_read
Next
Fileclose (li_filenum)

//display picture
P_1. Setpicture (lb_picture)

//3, the database
P_id=integer (left (string (ls_filename [I]), len (string (ls_filename [I])) - (4))

Updateblob question bank
Set the picture=: lb_picture
Where id=: p_id;
Next

If the sqlca. Sqlcode<> 0 then
Messagebox (" ", the sqlca. Sqlerrtext)

//messagebox (" prompt ", "update data error", stopsign! , ok!
return;
The else
Messagebox (" success ", "update data success")
End the if
  • Related