如何用delphi实现向oracle中上传各种文档(50分)

  • 主题发起人 主题发起人 sssdamn
  • 开始时间 开始时间
S

sssdamn

Unregistered / Unconfirmed
GUEST, unregistred user!
如何用delphi实现向oracle中上传各种文档,如word,excel等
 
往blob字段写入便可
 
怎样往blob字段写入阿?写详细点好吗
 
if not (Query.State in [dsInsert, dsEdit]) then Query1.Insert;
Query1Images.LoadFromFile('c:/Windows/Waves.bmp');
Query1.Post;
 
比如可以将文档转为流
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;
 
后退
顶部