P
publisher
Unregistered / Unconfirmed
GUEST, unregistred user!
原程序如下:
procedure TForm1.Button1Click(Sender: TObject);
var
MemSize: Integer;
Buffer: PChar;
MyFile: TFileStream;
Stream: TBlobStream;
begin
MyFile:=Tfilestream.create('c:/1.doc',fmopenread);
with table1 do
begin
Open;
insert;
Stream := TBlobStream.Create(FieldByName('content') as TBlobField, bmWrite);{‘Doc’为BLOB字段名}
MemSize := MyFile.Size;
Inc(MemSize); {Make room for the buffer's null terminator.}
Buffer := AllocMem(MemSize); {Allocate the memory.}
try
Stream.Seek(0, soFromBeginning); {Seek 0 bytes from the stream's end point}
MyFile.Read(Buffer^,MemSize);
Stream.Write(Buffer^,MemSize);
finally
MyFile.Free;
Stream.Free;
end;
try
Post;
except
on E: EDatabaseError do
{ if HandelException(E)<>0 then
exit
else
raise;
end;
exit; }
end;
Doc_ole.CreateObjectFromFile('c:/1.doc',False);
Doc_ole.Run;{Doc_ole为ToleContainer构件名}
end;
显示project project1.exe raised exception class edbengineerror whith message
invalid blob length.'. process stopped use step or run to continue
继续则可以在容器中显示文件,请问为什么?急急!!!请高手回答
create table table1(name varchar2(10),doc blob); //创建表table1
procedure TForm1.Button1Click(Sender: TObject);
var
MemSize: Integer;
Buffer: PChar;
MyFile: TFileStream;
Stream: TBlobStream;
begin
MyFile:=Tfilestream.create('c:/1.doc',fmopenread);
with table1 do
begin
Open;
insert;
Stream := TBlobStream.Create(FieldByName('content') as TBlobField, bmWrite);{‘Doc’为BLOB字段名}
MemSize := MyFile.Size;
Inc(MemSize); {Make room for the buffer's null terminator.}
Buffer := AllocMem(MemSize); {Allocate the memory.}
try
Stream.Seek(0, soFromBeginning); {Seek 0 bytes from the stream's end point}
MyFile.Read(Buffer^,MemSize);
Stream.Write(Buffer^,MemSize);
finally
MyFile.Free;
Stream.Free;
end;
try
Post;
except
on E: EDatabaseError do
{ if HandelException(E)<>0 then
exit
else
raise;
end;
exit; }
end;
Doc_ole.CreateObjectFromFile('c:/1.doc',False);
Doc_ole.Run;{Doc_ole为ToleContainer构件名}
end;
显示project project1.exe raised exception class edbengineerror whith message
invalid blob length.'. process stopped use step or run to continue
继续则可以在容器中显示文件,请问为什么?急急!!!请高手回答
create table table1(name varchar2(10),doc blob); //创建表table1