对于大图片,为何存取出错

seasol 2003-05-25 02:04:54
我已在各位大师的帖子中学会了如何将图片存入数据库,并取出和显示。

但如果图片过大,仍然可以存储和取出,但是通过图片控件显示,则出现
“Not a jpg file:starts with 0x7d 0x93”

这是为什么,我使用的是PB9.0/Sql Server2000
...全文
32 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
seasol 2003-05-30
  • 打赏
  • 举报
回复
用selectblob一次最多只能读出32K数据,
再没有别的方法了吗?
seasol 2003-05-25
  • 打赏
  • 举报
回复
sqlca.autocommit=true这句话有,可还是不行。

楼上的方案,可能不太理想

hbhdyn 2003-05-25
  • 打赏
  • 举报
回复
超出sqlserver最大blob值限制了, 用sybase的或存成两个以上字段。
cooltnt 2003-05-25
  • 打赏
  • 举报
回复
用updateblob和selectblob时sqlca.autocommit必须为true
seasol 2003-05-25
  • 打赏
  • 举报
回复
我的代码与楼上的相同,
存入时的blob为34605字节,
取出时,长度为32767字节,

不知这是为何?
joss 2003-05-25
  • 打赏
  • 举报
回复
保存图片时:
string ls_path,ls_name
long ret,loops,ll_filenum,flen,ll_readfile
blob lb_pic,b
int i,li_id
li_id=integer(trim(sle_1.text))
ret=getfileopenname("选择图片",ls_path,ls_name,"aaaa","图片文件(bmp),*.bmp,图片文件(jpg),*.jpg,图片文件(jpeg),*.jpeg")
if ret <> 1 then return
flen=filelength(ls_path)
messagebox("",flen)
p_1.picturename=ls_path
ll_filenum=fileopen(ls_path,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
lb_pic=blob("")
for i =1 to loops //这里便是循环
ll_readfile=fileread(ll_filenum,b)
lb_pic=lb_pic + b
next
fileclose(ll_filenum)
//ole_1.insertfile(ls_name)
updateblob u_sys_set_other set bmp_whole= :lb_pic where iid=1;
commit;

写入时:
//从数据库中取图片:
blob lb_pic
//messagebox("",integer(sle_1.text))
int li_id
//li_id=integer(sle_1.text)
selectblob bmp_whole into :lb_pic from u_sys_set_other where iid=1;
if sqlca.sqlcode <> - 1 then
if len(lb_pic)> 0 then
p_1.setpicture(lb_pic)
end if
else
messagebox("","")
p_1.picturename=""
end if

注意是,将图片读出写入数据库需要用到循环
将图片从数据库读出并写入图片控件则不用循环!
以上例子能保存300K一张图片没有问题!(再大的没有试过!)
seasol 2003-05-25
  • 打赏
  • 举报
回复
可否告之如何进行循环写入和读出
tommyhuanglei 2003-05-25
  • 打赏
  • 举报
回复
你如果图片大于64k就要循环写入,循环读出来,要判断一下!
tommyhuanglei@sohu.com
joss 2003-05-25
  • 打赏
  • 举报
回复
呵呵!我没有遇到过这个错误提示!!
你先将图片值读出看有多大,是否能确定是大小的问题,如果是这样,改用OLE图片控件吧!
wangshenkai 2003-05-25
  • 打赏
  • 举报
回复
你无敌有了,,,
答案,,,
给我一分
,.,.,.,.,.,.

1,079

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 相关问题讨论
社区管理员
  • 基础类社区
  • WorldMobile
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧