L
lijun175165721
Unregistered / Unconfirmed
GUEST, unregistred user!
//****************************************************************************//
//把word文档以ole数据形式存入数据库,再用OleCOntainer控件把它从数据库中显示出来
//****************************************************************************//
procedure TForm1.Button2Click(Sender: TObject);
var
FileName:String;
FileStream:TFileStream;
BlobStream:TBlobStream;
BufferChar;
MemSize:Integer;
begin
if OpenDialog1.Execute then
begin
FileName:=OpenDialog1.FileName;
end;
try
FileStream:=TFileStream.Create(FileName,fmOpenRead);
MemSize:=FileStream.Size;
inc(MemSize);
Buffer:=AllocMem(MemSize);
FileStream.Seek(0,SoFromBeginning);
FileStream.Read(Buffer^,MemSize);
ADOTable1.Append;
BlobStream:=TBlobStream.Create(ADOTable2.FieldByName('Doc') as TBlobField,bmWrite);
BlobStream.Write(Buffer^,MemSize);
ADOTable1.Post;
finally
BlobStream.Free;
FileStream.Free;
ADOTable2.Close;
end;
end;
上面的程序运行时老是提示内存出错!!!,请各位大虾指点!!!
//把word文档以ole数据形式存入数据库,再用OleCOntainer控件把它从数据库中显示出来
//****************************************************************************//
procedure TForm1.Button2Click(Sender: TObject);
var
FileName:String;
FileStream:TFileStream;
BlobStream:TBlobStream;
BufferChar;
MemSize:Integer;
begin
if OpenDialog1.Execute then
begin
FileName:=OpenDialog1.FileName;
end;
try
FileStream:=TFileStream.Create(FileName,fmOpenRead);
MemSize:=FileStream.Size;
inc(MemSize);
Buffer:=AllocMem(MemSize);
FileStream.Seek(0,SoFromBeginning);
FileStream.Read(Buffer^,MemSize);
ADOTable1.Append;
BlobStream:=TBlobStream.Create(ADOTable2.FieldByName('Doc') as TBlobField,bmWrite);
BlobStream.Write(Buffer^,MemSize);
ADOTable1.Post;
finally
BlobStream.Free;
FileStream.Free;
ADOTable2.Close;
end;
end;
上面的程序运行时老是提示内存出错!!!,请各位大虾指点!!!