在Power Builder中读写SYBASE的Image数据 []

myclife 2003-05-14 04:02:09
加精

  
在使用Power Builder开发应用时,已经有越来越多的用户注重Power Builder的像处理能力,尤其当你选择SYBASE SQL Server为数据源时,SYBASE支持Image数据类型的特性,使Power Builder处理图像的能力得到更好的发挥。SYBASE与Power Builder融洽的结合,为用户多媒体程序设计提供了最佳的解决方案。

  以下举例,给你提供一种思路解决读写图像的方法:

  以下Power Script是读取bitmap文件(包括大于32KB的bitmap文件),并插入到SQL SERVER 的TEST表中。

从SinglelineEdit中取bitmap的文件名。
如果大于32KB,则以32KB为单位读取并拼接在tot_b变量中。
在SQL SERVER中建TEST表,有两列id类型char,image类型image。
将tot_b的内容存入TEST表中。
string id="01"
int fnum, i, loop, ctr, ret
long flen ,bytes_read, new_pos=0
blob b,tot_b
flen = FileLength{"d:\pb3\" + trim(sle_1.text) + ".bmp")
fnum = FileOpen ("d:\pb3\" + trim(sle_1.text) + ".bmp",streammode!)
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
FOR i = 1 to loops
bytes_read = FileRead(fnum, b)
tot_b = tot_b + b
new_pos = new_pos + bytes_read
FileSeek(fnum, new_pos, FromBeginning !)
NEXT
FileClose(fnum)
connect;
INSERT INTO test (id, image)
values (:id, :tot_b) ; (Note: Field image cannot be NULL)
disconnect;
connect;
UPDATEBLOB test SET image = :tot_b
WHERE id = :id;
disconnect;

  以下PowerScript是从TEST表中读出image数据,并送到p_1(picture Conntrol)中

blob emp_id_pic
string id = "01"
int ctr
connect ;
SELECTBLOB. image
INTO : emp_id_pic
FROM test
WHERE id = : id;
disconnect ;
ctr = SetPicture (p_1, emp_id_pic)

  注:插入图像时,Transaction log增长相当快,所以要有大一些的log device而且常做Dump Tran database-name with truncate-only。

...全文
59 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复
tchatcha 2003-05-14
  • 打赏
  • 举报
回复
http://www.sybase.com.cn/cn/content/goto.jsp?resID=0

有现成的例子可是SYBASE公司写的

1,077

社区成员

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

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