如何用pb实现MSACCESS数据库的图片字段存取
Kukoc:给个例子:
SQLCA.AutoCommit = TRUE
//取文件长度
ll_flength = FileLength(ls_bmpname)
if IsNull(ll_flength) then ll_flength = -1
if ll_flength < 0 then
return
end if
//打开文件
li_FileNum = FileOpen(ls_bmpname, StreamMode!, Read!)
if li_FileNum < 0 then
FileClose(li_FileNum)
Messagebox("错误信息", "打开图文件 " + ls_bmpname + " 失败!", Exclamati
on!)
return
end if
//读文件数据 ,大于32K要多次循环取
li_loopnum = ll_flength / 32765 + 1
for li_loop = 1 to li_loopnum
FileRead(li_FileNum, lbb_tmp)
lbb_bmp = lbb_bmp + lbb_tmp
next
//关闭文件
FileClose(li_FileNum)
//保存图片信息到数据库中
SELECT BMPID INTO :ll_tmp FROM TABLENAME WHERE BMPID = :li_id;
if sqlca.sqlcode = 100 then
INSERT INTO TABLENAME ( BMPID, BMPDATA ) VALUES ( :li_id, :lbb_bmp ) ;
end if
if sqlca.sqlcode <> 0 then
ls_msg = SQLCA.SQLErrText
ROLLBACK;
Messagebox("错误信息", "数据库操作失败!~r~n" + ls_msg, Exclamation!)
return
end if
UPDATEBLOB TABLENAME SET BMPDATA = :lbb_bmp WHERE BZID = :lizid;
ls_msg = SQLCA.SQLErrText
if ls_msg <> '' then
ROLLBACK;
Messagebox("错误信息", "保存图片信息失败!~r~n" + ls_msg, Exclamation!)
return
end if
COMM99v;
Messagebox("信息", "保存图片信息成功!")