如何将一个文件放到数据库的Blob字段中去。(50分)

  • 主题发起人 主题发起人 完颜康
  • 开始时间 开始时间

完颜康

Unregistered / Unconfirmed
GUEST, unregistred user!
数据上传后,怎么将Blob字段中的文件流恢复成“文件”,读出来
 
搜索一下word+数据库吧,已经友人解决了
 
var fld:TField;

fld:=CurTable.FieldByName('PictureData');
CurTable.edit;
with(fld as tblobfield)do loadfromfile(edit1.Text); //输入
with(fld as tblobfield)do savetofile(fileName); //输出
 
TBLOBFIELD(TABLE1.FIELDS[0]).SAVETOFILE(YOURFILENAME)
 
Table1BlobField.SaveToFile('c:/aaa');
 
以下是我做过的一个从BLOB字段读取照片的代码
其中FILENAME是存放文件名的字段
PICTURE是存放照片的BLOB字段
希望对你有用
procedure getpic;
var
bs:tadoblobstream;
begin
..
bs:=tadoblobstream.Create(tblobfield(fieldbyname('picture')),bmread);
if bs.Size<=0 then exit;
try
picname:=extractfilepath(application.exename)+'temp';
picname:=picname+extractfileext(fieldbyname('filename').value);
bs.savetofile(picname);
imgpic.picture.loadfromfile(picname);
finally
bs.free;
end;
end;
 
多人接受答案了。
 
后退
顶部