我用的是pb 9.0+sql2000.
代碼如下:
//filedisk
//fileread
string filepath,filename
string ll_path
int i,f_num,loops,j
long f_long,sum_read,p_new
blob tot_b,b,pic
p_new=0
i=getfileopenname('請選擇圖片',filepath,filename,"all Files (*.jpg),*.bmp,*.jpg");
sle_path.text=filepath
f_long=filelength(trim(sle_path.text))
f_num=fileopen(trim(sle_path.text),STREAMMODE!,READ!,LOCKREAD!)
//以每次讀取32K為基礎,決定讀取幾次
if f_long>32765 then
if mod(f_long,32765)=0 then
loops=f_long/32765
else
loops=f_long/32765+1
end if
else
loops=1
end if
//回圈讀取
for i=1 to loops
sum_read=fileread(f_num,b)
tot_b=tot_b+b
p_new=p_new+sum_read
fileseek(f_num,p_new, FROMBEGINNING!)
next
fileclose(f_num)
p_1.visible=true
SetPicture(p_1,tot_b)
sqlca.autocommit=true
select count(*) into :j from s_orgcode_pic
where orgcode=:ll_depot;
if j=0 or isnull(j) then
insert into s_orgcode_pic(orgcode,pic ,createtime )
values (:ll_depot,:tot_b,getdate());
end if
if sqlca.sqlcode<>0 then
messagebox("提示","生成資料失敗"+SQLCA.SQLErrText)
return 1
end if
updateblob s_orgcode_pic set pic=:tot_b
where orgcode=::ll_depot;
sqlca.autocommit=false
selectblob pic into :pic
from s_orgcode_pic where orgcode=:ll_depot;
//p_1.SetPicture(pic)
資料庫表create table s_orgcode_pic
(orgcode varchar(12),
pic image null ,
createtime datetime)
執行完,在資料庫中有資料,就是用selectblob后無法顯示圖片.
我把SetPicture(p_1,tot_b) 放在資料庫存盤前執行是能夠顯示的.放到selectblob就不可以?
有達人能幫我看看嗎?
uj5u.com熱心網友回復:
blob寫入要先寫入那一行資料,建表時允許blob欄位(image型別)為空,然后在updateblob(autocommit=true).直接insert不行。轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/86509.html
標籤:數據庫相關
