PB updateblob 数据长度截断现象
存入数据代码:
handle = fileopen(s_file, streammode!)
len = filereadex(handle, im)
len1 = len(im) //此处我调试看了,长度正确是 6KB
if len > 0 then
sqlca.autocommit = true
//insert into t_mreport (日期, 报告编号, 报告名称, 报告存档) values ('2008-1-1', 0, '测试1', 'sadadasd') using sqlca;
//insert into t_mreport (日期, 报告编号, 报告名称, 报告存档) values ('2008-1-1', 0, '测试1', convert(varbinary,:im)) using sqlca;
updateblob t_mreport set 报告存档 = :im where 序号 = 1;
if sqlca.sqlcode = 0 then
commit;
messagebox("成功!","更新数据库成功!")
else
rollback;
messagebox("失败!","更新数据库失败!" + sqlca.sqlerrtext )
end if
sqlca.autocommit = false
end if
下面是读出代码:
blob im
string s_file, s_file_dest
long handle
long len, len1
s_file = "E:\workspace\PB10.0\fileTest_d_connect_002.doc"
s_file_dest = "E:\workspace\PB10.0\fileTestdump_d.doc"
selectblob 报告存档 into :im from t_mreport where 序号 = 1;
len1 = len(im) //此处调试查看是 6KB 的一半
if sqlca.sqlcode = 0 and sqlca.sqlnrows > 0 then
handle = fileopen(s_file_dest, streammode!, write!, shared!, replace!)
if handle > 0 then
len = filewriteex(handle, im)
fileclose(handle)
end if
end if
所以我怀疑是存入是截断的,注意数据库:sql2005中,字段是 varbinary(max).
请大家指点!