PB + SQL SERVER 中存放图片与读取图片的问题。
代码如下:
integer li_FileNum, loops, i
integer li_filenum2
long flen, bytes_read, new_pos
blob b, tot_b
transaction sqlca_blob
sqlca_blob=create transaction
sqlca_blob.DBMS ="MSS Microsoft SQL Server 6.x"
sqlca_blob.Database = "cj_club"
sqlca_blob.ServerName = "wxhx-zdy"
sqlca_blob.LogId = "sa"
sqlca_blob.AutoCommit = True
connect using sqlca_blob;
string str_card_id
string str_add_card
str_card_id="C0051"
str_add_card="S0000"
selectblob c_photo into :tot_b,Len(tot_b) as lll
from T_member
where c_card_id=:str_card_id and c_add_card=:str_add_card
using sqlca_blob;
messagebox("sadjf",string(Len(tot_b)));
string str_card
str_card=""
select c_card_id into :str_card
from T_member
where c_card_id=:str_card_id and c_add_card=:str_add_card
using sqlca_blob;
destroy sqlca_blob;
messagebox("",str_card);
为什么在更新与读取时,数据均取不出来。
请考各位。
问题点数:50、回复次数:4Top
1 楼lincanwen(密码错误)回复于 2002-07-31 16:15:38 得分 40
读:
blob ib_totalpic
SQLCA.AutoCommit = True
SELECTblob 图片 INTO :ib_totalpic
FROM 表 WHERE 条件
USING sqlca;
if SQLCA.SQLCode <> -1 then
if len(ib_totalpic) >0 then
p_1.SetPicture(ib_totalpic)
else
p_1.picturename= "" p_1.picturename= ""
end if
end if
SQLCA.AutoCommit = false
存:
//以下调用打开文件对话框,选择图片
integer li_FileNum, loops, i,ret
long flen, bytes_read, new_pos
blob b
string txtname, named
string Filter = "bitmap Files (*.bmp)"
SetPointer(HourGlass!)
ret = GetFileOpenName("Open Bitmap", txtname, &
named, defext, filter)
if ret<>1 then return
ib_selectpic=true
flen = FileLength(txtname)
li_FileNum = FileOpen(txtname, &
StreamMode!, Read!, LockRead!)
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
new_pos = 1
ib_totalpic = blob("")
FOR i = 1 to loops
bytes_read = FileRead(li_FileNum, b)
ib_totalpic = ib_totalpic + b
NEXT
FileClose(li_FileNum)
p_1.SetPicture(ib_totalpic)
SQLCA.AutoCommit = true
UPDATEBLOB 表 set 图片 = :ib_totalpic
WHERE 条件
USING sqlca;
SQLCA.AutoCommit = falseTop
2 楼zenglong(zenglong)回复于 2002-07-31 16:25:26 得分 5
你的代码selectblob c_photo into :tot_b,Len(tot_b) as lll中的Len(tot_b) as lll不知有何用处?是否正确?Top
3 楼smilelhh(blue)回复于 2002-07-31 16:31:06 得分 5
因为fileread()只能读32765个字节,超过的就要分次读取。
用len()是为了控制循环。Top
4 楼deyi(江湖浪子)回复于 2002-08-21 12:54:04 得分 0
谢谢各位,问题已经解决了,没有来得及给各位加分,抱歉!Top




