比如可以将文档转为流
procedure SaveToOracle;
var
MyStream: TMemoryStream;
FileStream: TFileStream; // 将写入的文件
size: Cardinal;
iPosition: Cardinal;
blocksize:Cardinal;
begin
blocksize:=1024; //1M
prob.StepBy(1);
if OpenDialog1.Execute then
begin
if OpenDialog1.FileName='' then exit;
if application.MessageBox('真的要导入这个文件吗?','提示',mb_okcancel)=idok then
begin
FileStream:=TFileStream.Create(OpenDialog1.FileName,fmOpenRead);
MyStream:=TMemoryStream.Create();
MyStream.Position:=0;
size:=FileStream.Size;
prob.Max:=size div 1024;
iPosition := 0;
ADOQ_input.Close;
ADOQ_input.SQL.Clear;
ADOQ_input.SQL.Add('update file_ver set ver='+#39+edit1.Text+#39);
ADOQ_input.SQL.Add(',file_ver=:ID where uid=''1''');
while iPosition<size do
begin
application.ProcessMessages;
prob.Step:=1;
prob.StepIt;
FileStream.Position:=iPosition;
if (iPosition+BlockSize)<=size then
MyStream.CopyFrom(FileStream,BlockSize)
else
MyStream.CopyFrom(FileStream,Size-iPosition);
iPosition:=iPosition+BlockSize;
MyStream.Position:=iPosition;
label2.Caption:='正在读取文件,请稍后.....';
end;
Timer1.Enabled:=true;
ADOQ_input.Parameters.ParamByName('ID').LoadFromStream(MyStream,ftTypedBinary);
label2.Caption:='正在存储文件,请稍后.....';
ADOQ_input.ExecSQL;
Timer1.Enabled:=false;
FileStream.Free;
MyStream.Free;
showmessage('数据导入成功');
end;
end;
end;