为何我的blob数据总是存不进去,错误返回值为-1?

xxxuan 2001-09-14 09:49:47
为何我的blob数据总是存不进去,错误返回值为-1?
integer fh,ret
blob tmp_php,lb_php
string filename,named,ls_bh,defext="bmp"
string filter="图形文件(*.bmp),*.bmp"
long fsize
int num,i //从磁盘选择文件
ret=getfileopenname("选择文件",filename,named,defext,filter)
messagebox("kk","succed!"+string(ret))
if ret=1 then
fsize=filelength(filename)
fh=fileopen(filename,streammode!)
messagebox("fh","succed!"+string(fsize)+" "+string(fh))
num=int(fsize/32765)+1
if fh<>-1 then
for i=1 to num
fileread(fh,tmp_php)
lb_php=lb_php+tmp_php
next
fileclose(fh)
end if
end if
ulong mid
mid=dw_1.getrow()

UPDATEBLOB books
SET book_cover = :lb_php
WHERE id=:mid;

messagebox("code",string(sqlca.sqlcode))
if sqlca.sqlcode<>0 then
messagebox("提示信息","保存失败!",exclamation!,OK!,1)
rollback using sqlca;
else
commit using sqlca;
end if
为何我的blob数据总是存不进去,错误返回值为-1?
...全文
129 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
yahoosohu 2001-09-14
  • 打赏
  • 举报
回复
1 数据库中的该图像字段必须预存有值,例如:'101'这样才能把该图片存进去
2 updateblob语句这样写:sqlca.autocommit = true
UPDATEBLOB books
SET book_cover = :lb_php
WHERE id=:mid;
sqlca.autocommit = false
3 不能用sqlca.sqlcode 而用以下语句
IF Emptran.SQLNRows > 0 THEN
COMMIT USING Emp_tran ;

END IF
sclt 2001-09-14
  • 打赏
  • 举报
回复
sqlca.AutoCommit = True
UPDATEBLOB books
SET book_cover = :lb_php
WHERE id=:mid

using sqlca;

IF sqlca.SQLNRows > 0 THEN
COMMIT USING sqlca;

END IF
sqlca.AutoCommit = false
cool18_2k 2001-09-14
  • 打赏
  • 举报
回复
忘了说,你用的是 SQL ANYWHERE 数据库吧。
那么,请将 SQLCA 的 AutoCommit 属性的值置为 True。

这个在 updateblob 语句帮助的最下面写的很清楚。
cool18_2k 2001-09-14
  • 打赏
  • 举报
回复
我说。。。。。
你看不动这段英文的意思么?
To make sure the update affected at least one row, check the SQLNRows property of SQLCA or the transaction object. The SQLCode or SQLDBCode property will not indicate the success or failure of the UPDATEBLOB statement.

翻译的不好,还请包涵:
请检查 SQLCA 或 transaction 对象的 SQLNRows 属性来确认最后更新的行。
SQLCode 或 SQLDBCode 属性并不体现 UPDATEBLOB 语句的成功与否。
xxxuan 2001-09-14
  • 打赏
  • 举报
回复
我找不到sqlnrows 属性,说明里说的是:
Error handling It is good practice to test the success/failure code after executing an UPDATEBLOB statement. To make sure the update affected at least one row, check the SQLNRows property of SQLCA or the transaction object. The SQLCode or SQLDBCode property will not indicate the success or failure of the UPDATEBLOB statement.
好象也是用sqlcode检测的.
可是为何存不进去,我的数据库为anywhere的,急急!
cool18_2k 2001-09-14
  • 打赏
  • 举报
回复
用 updateblob 是不能检查 sqlcode 的值的。
应该检查 sqlnrows 属性的值,是 1 的话,就应该成功了。
还有,如果你用的sqlserver ,autocommit 属性要置为 true。这样,事物就无效了。

1,108

社区成员

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

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