sql server 表的字段类型为image,我把一个10M的文件读进blob变量,再updateblob,sql xerver数据库会增加20M,日志文件也增加20M以上,怎么不是10M呢?用selectblob读取该数据到一个blob变量,长度只有32K,怎么回事呢?在执行上述语句前已设置sqlca.autocommit=true.
...全文
2027打赏收藏
图片文件保存到sql server库和读取
sql server 表的字段类型为image,我把一个10M的文件读进blob变量,再updateblob,sql xerver数据库会增加20M,日志文件也增加20M以上,怎么不是10M呢?用selectblob读取该数据到一个blob变量,长度只有32K,怎么回事呢?在执行上述语句前已设置sqlca.autocommit=true.
long ll_filelen
int li_filenum,li_loops,li_counter
blob lb_read,lb_picture
string ls_photofile='aaa.jpg',ls_no //把程序目录下aaa.jpg保存到数据库
ls_no=dw_1.getitemstring(dw_1.getrow(),'no')//得到编号
ll_filelen=filelength(ls_photofile)
li_filenum=fileopen(ls_photofile,streammode!,read!,lockread!)
if ll_filelen > 32765 then
li_loops=((ll_filelen - 1)/32675)+1
else
li_loops=1
end if
for li_counter=1 to li_loops
fileread(li_filenum,lb_read)
lb_picture=lb_picture+lb_read
next
fileclose(li_filenum)
p_1.setpicture(lb_picture)
sqlca.autocommit=true
updateblob t_health
set picture=:lb_picture
where no = :ls_no;
if sqlca.sqlnrows>0 then
commit;
else
rollback;
return 0
end if
sqlca.autocommit=false
return 1
else
rollback;
return 0
end if