这是我程序中的两段,没有修改,是针对SQL Server的。
function TFrmM_Design.DBToDisk(Query_String, Column_Name, Target_Name: string): Boolean;
var
Dot_Stream: TFileStream;
begin
{从数据库中取出文稿}
with aqry_Tmp do
begin
Close;
SQL.Text := Query_String;
Open;
end;
{将数据库中Image字段保存到硬盘下,存为Doc文件}
Dot_Stream := TFileStream.Create(Target_Name, fmOpenWrite or fmCreate);
Dot_Stream.Position := 0;
TBlobField(aqry_Tmp.FieldByName(Column_Name)).SaveToStream(Dot_Stream);
Dot_Stream.Free;
aqry_Tmp.Close;
Result := True; //所有任务彻底完成,Function返回True
end;
function TFrmM_Design.DiskToDB(l_missive_name_no, Target_Name: string): Boolean;
var
Dot_Stream: TFileStream;
begin
with aqry_Tmp do
begin
Close;
SQL.Clear;
SQL.Text := 'Select type_dot from s_d_missive where missive_name_no=''' + missive_name_no + '''';
Open;
end;
aqry_Tmp.Edit; {直接进入Edit,取消Append}
Dot_Stream := TFileStream.Create(Target_Name, fmShareDenyNone);
Dot_Stream.Position := 0;
TBlobField(aqry_Tmp.FieldByName('type_dot')).loadfromStream(Dot_Stream);
aqry_Tmp.Post;
Dot_Stream.Free;
Result := True; //一切任务完成,返回True
end;