图片保存
String ls_file
ls_file=Trim(sle_file.text)
if IsNull(ls_file) or ls_file='' then
Messagebox("数据提示","请选择文件")
return
end if
if not FileExists(ls_file) then
Messagebox("数据提示","文件不存在")
return
end if
integer iOpen,iRead,iLoop,i
blob bReadData,bAllReadData
long ll_fileSize,bAllRead
ll_fileSize=filelength(ls_file)
iOpen=FileOpen(ls_file,StreamMode!,Read!,LockRead!)
iLoop=ll_fileSize/32765 + 1
for i=1 to iLoop
iRead=FileRead (iOpen,bReadData)
if i=1 then
bAllReadData=bReadData
else
bAllReadData=bAllReadData+bReadData
end if
next
FileClose(iOpen)
long ll_maxid,count
String ls_maxid,ls_newId
String ls_note
String ls_filename
ls_note=sle_note.text
ls_filename=sle_name.text
select count(*)
into :count
from z_photo
where photoname=:ls_filename;
if count>0 then
Messagebox("数据提示","库中已有同名文件")
return
end if
select max(id)
into :ls_maxid
from z_photo;
if IsNull(ls_maxid) then ls_maxid='0'
ll_maxid=long(ls_maxid)
ls_newId=String(ll_maxid+1,'0000')
INSERT INTO z_photo( id,photo,note,photoname)
VALUES ( :ls_newId,
null,
:ls_note,
:ls_filename) ;
if sqlca.sqlcode<>0 then goto Error
commit;
Updateblob z_photo Set photo =:bAllReadData Where id=:ls_newId;
if SQLCA.SQLNRows>0 Then
COMMIT;
Messagebox("信息", "保存图片信息成功!")
else
goto Error
end if
return
Error:
rollback;
Messagebox("信息", "保存图片信息失败!")