以文本方式查看主题

-  蓝色快车PB俱乐部论坛  (http://pb.besoft.com.cnhttp://pb.besoft.com.cn/bbs/index.aspindex.asp)
--  PowerBuilder MIS编程  (http://pb.besoft.com.cnhttp://pb.besoft.com.cn/bbs/index.aspbbs.asp?boardid=1)
----  各位老大帮看看吧  (http://pb.besoft.com.cnhttp://pb.besoft.com.cn/bbs/index.aspdispbbs.asp?boardid=1&rootid=748&id=1018)


--  作者:chnama
--  发布时间:2003/8/5 13:17:11

--  各位老大帮看看吧
integer li_FileNum, loops, i
long ll_len

long flen, bytes_read, new_pos

blob b, tot_b

string ls_pic

ls_pic = "e:\1.bmp"

// Set a wait cursor

SetPointer(HourGlass!)

// Get the file length, and open the file

flen = FileLength(ls_pic)

li_FileNum = FileOpen(ls_pic, &
 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
 
 ll_len = len(tot_b)

NEXT

FileClose(li_FileNum)

p_1.setpicture(tot_b)

int li_id
select isnull(max(id),0)
into :li_id
from img_base;

li_id = li_id + 1

insert into img_base values(:li_id,null);
if sqlca.sqlcode <> 0 then
 messagebox("insert",sqlca.sqlerrtext)
 rollback;
 return
end if

sqlca.autocommit = true
updateblob img_base
set img = :tot_b
where id = :li_id;
sqlca.autocommit = false

if sqlca.sqlnrows = 0 then
 messagebox("update",sqlca.sqlerrtext)
 rollback;
 return
else
 commit;
end if

为什么总说“在关键字‘NULL’附近有语法错误”啊?


--  作者:shjychina
--  发布时间:2003/8/5 14:05:05

--  
应该这么写
select max(id) into :li_id from img_base;

if isnull(li_id ) then li_id = 0

因为isnull()是pb的函数,数据库不认识,在这里应该写数据库函数


--  作者:chnama
--  发布时间:2003/8/5 14:52:39

--  
ISNULL
使用指定的替换值替换 NULL。

语法
ISNULL ( check_expression , replacement_value )


--  作者:shjychina
--  发布时间:2003/8/6 9:15:19

--  
你用的数据库支持就可以,那就需要参考数据库手册了
--  作者:chnama
--  发布时间:2003/8/6 9:32:02

--  
忘了说啦,数据库是SQL Server 2000
--  作者:shjychina
--  发布时间:2003/8/8 10:32:44

--  
可能是pb的问题吧,SQL Server 2000 里面可以使

你在pb的isql里面试验一下


--  作者:chnama
--  发布时间:2003/8/13 16:36:30

--  
在那里怎么把图片读进来啊
--  作者:cmaboy
--  发布时间:2003/8/16 19:06:43

--  
updateblob

">