PB9.0 5507 存取SQLServer库中图片大于32K的问题

weidegong 2004-12-24 09:57:56
字段类型image,大小超过32K时,就无法存取,请高手指点。

用样的代码在PB7下可以。

急急急!
...全文
343 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
weidegong 2004-12-28
  • 打赏
  • 举报
回复
感谢各位大力支持;

此问题最终解决,只能读取32K时,使用ODBC连接

改为不使用ODBC连接,代码运行OK
weidegong 2004-12-27
  • 打赏
  • 举报
回复
在PB9+SQLServer2000里能保存,但是只能读取32K

同样代码在PB7中,OK。

各位不妨一试;上述各位所用PB版本是否9?
amekoxiao 2004-12-25
  • 打赏
  • 举报
回复
从数据库读取时用SELECTBLOB
从文件读取时用循环FILEREAD

没有问题的,我的一个文档管理系统就是这样实现的
balloonman2002 2004-12-24
  • 打赏
  • 举报
回复
从数据库读取时用SELECTBLOB
从文件读取时用循环FILEREAD
tmdxht 2004-12-24
  • 打赏
  • 举报
回复
你试试看把这段这么写,我也不知道正不正确呵呵:(因为我不知道气球兄这种做法是不是能把文件读取完全,但是PB的帮助里是和气球兄写的一样的)
FOR i = 1 to loops
fileseek(li_filenum,i*32765+1,fromcurrent!)
bytes_read = FileRead(li_FileNum, b)
tot_b = tot_b + b

NEXT
weidegong 2004-12-24
  • 打赏
  • 举报
回复
balloonman2002:
目前用上述办法,保存一个大于32K的Word文件,OK;读取到BLOB变量(BLB_tmp),长度只有32K,并且赋值到OLE控件时报错(OLE_1.objectdata=BLB_tmp)。
balloonman2002 2004-12-24
  • 打赏
  • 举报
回复
超过32K时FILEREAD的方法如下,FILEWRITE同样存在问题,可以参考修改:

****************************************************************

This example reads a file exceeding 32,765 bytes. After the script has read the file into the blob tot_b, you can call the SetPicture or String function to make use of the data, depending on the contents of the file:

integer li_FileNum, loops, i

long flen, bytes_read, new_pos

blob b, tot_b

// Set a wait cursor

SetPointer(HourGlass!)

// Get the file length, and open the file

flen = FileLength(sle_filename.Text)

li_FileNum = FileOpen(sle_filename.Text, &
StreamMode!, Read!, LockRead!)

// Determine how many times to call FileRead

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

// Read the file

new_pos = 1

FOR i = 1 to loops
bytes_read = FileRead(li_FileNum, b)
tot_b = tot_b + b

NEXT

FileClose(li_FileNum)
balloonman2002 2004-12-24
  • 打赏
  • 举报
回复
用selectblob/updateblob语句, 并结合循环式FILEREAD/FILEWRITE读写文件(解决大于32K问题),代码详见:

http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=201309
jb99334 2004-12-24
  • 打赏
  • 举报
回复
大于32K要多次循环取
http://www.jiafangyifang.com/news/more/news.php?id=44346
http://www.cnread.net/cnread1/dnwl/cxsj/pb/xljz/027.htm
mnsiii 2004-12-24
  • 打赏
  • 举报
回复
没问题的,你使用selectblob 字段 into :blob变量 from 表名 where 条件;

然后就用ole_1.Objectdata = blob变量,就显示出来了

存的时候也好办,楼上地说的很清楚了。不再赘述

752

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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