读书人

还是delphi oracle存取照片有关问题

发布时间: 2013-08-26 12:17:40 作者: rapoo

还是delphi oracle存取照片问题
procedure TMainForm.btnInputPhotoInfoClick(Sender: TObject);
var
bRst: Boolean;
msStream: TMemoryStream;
iSize: Int64;
begin
if img111.Picture.Graphic = nil then
begin
ShowMsg('照片不能为空');
Exit;
end;
msStream := TMemoryStream.Create;
img111.Picture.Graphic.SaveToStream(msStream);
msStream.Position := 0;
bRst := SaveReaderPhoto(Trim(edtCode112.Text),msStream);
if bRst then
begin
ShowMsg('保存照片成功');
end
else ShowMsg('保存照片失败');
FreeAndNil(msStream);
end;

function SaveReaderPhoto(const A_sBarCode: string;
A_msStream: TMemoryStream): Boolean;
begin
Result := False;
with SysDM.OraqryReaderInfoData do
begin
SQL.Text :=
'update readerinfo set reader_photo= empty_blob()' +
' where reader_barcode = :BarCode';
ParamByName('BarCode').AsString := Trim(A_sBarCode);
ExecSQL;
Close;
SQL.Text :=
'update readerinfo set reader_photo = :photo' +
' where reader_barcode = :BarCode';
ParamByName('BarCode').AsString := Trim(A_sBarCode);
A_msStream.Position := 0;
ParamByName('photo').LoadFromStream(A_msStream,ftBlob);
try
ExecSQL;
Result := True;
except
on E:Exception do
begin
WriteLog('Melinets_SaveReaderPhoto/' + E.Message);
end;
end;
Close;
end;
end;
以上是源码,但是存入到库以后,是空的,谁能帮我看看啊,


[解决办法]
代码找不出错

看下msStream值是否正确, 数据表字段是否blob
[解决办法]

引用:
msStrema.size的值大于0。我就真的不明白了。网上好多帖子都这样的,但是我的代码就是存不进去照片。

数据表字段类型没问题吧
我没用过oracle, mssql, mysql之类都是用blob字段存放

读书人网 >.NET

热点推荐