這段代碼把圖片已經批量存盤到access資料庫,但是存盤的圖片都是被選擇的第一張圖片。比如:我先擇了10張圖片,它存盤的也是10張圖片,但是都是第一個檔案,2-10圖片沒有存盤。
如何改進這段代碼各位高手幫忙。
備注:被選擇的圖片名稱和資料庫ID一樣
string ls_photofile
integer li_filenum,p_id,i
integer li_loops
integer li_counter
blob lb_picture
long ll_filelen
blob ll_read
Long ll_num
string ls_pathname, ls_filename[]
integer li_value
//1、選擇圖片
li_value = GetFileOpenName("選擇照片", &
+ ls_pathname, ls_filename[], "圖片檔案","jpg File (*.jpg),*.jpg,bmp file(*.bmp),*.bmp,gif file(*.gif),*.gif")
IF li_value = 1 THEN
Elseif li_value=https://bbs.csdn.net/topics/-1 then
MessageBox("選擇照片","打開檔案錯誤!")
End If
ll_num = upperbound(ls_filename)
for i=1 to ll_num
//2、獲取圖片的二進制資料
//處理照片檔案資料開始
ls_photofile=ls_filename[i]
ll_filelen=filelength(ls_photofile)
li_filenum=fileopen(ls_photofile,streammode!,read!,lockread!)
if ll_filelen>32765 then
li_loops=((ll_filelen - 1) /32765)+1
else
li_loops=1
end if
?
//讀檔案
for li_counter=1 to li_loops
fileread(li_filenum,ll_read)
lb_picture=lb_picture+ll_read
next
fileclose(li_filenum)
//顯示圖片
p_1.setpicture(lb_picture)
//3、存入資料庫
p_id= integer(left(string(ls_filename[i]),len(string(ls_filename[i])) - 4))
updateblob 題庫
set 圖片=:lb_picture
where id =:p_id;
next
if sqlca.sqlcode<>0 then
messagebox("",sqlca.sqlerrtext)
//messagebox("系統提示","更新資料錯誤",stopsign!,ok!)
return;
else
messagebox("成功","更新資料成功")
end if
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/29867.html
標籤:腳本語言
