Z
zjm79
Unregistered / Unconfirmed
GUEST, unregistred user!
程序如下, 运行时报告undeclared indentifer'Tblobstream'
procedure TsampleForm.OpenDOCClick(Sender: TObject);
var
MemSize: Integer;
Buffer: PChar;
MyFile: TFileStream;
Stream: TBlobStream;
begin
OpenDialog1.Filter:='WORD文档(*.DOC)|*.DOC'
;{从对话窗选择文件}
if OpenDialog1.Execute then begin
MyFile:=TFileStream.Create
(OpenDialog1.FileName,fmOpenRead);
with table1 do {‘table1’为含BLOB字段的表名}
begin
Open;
Edit;
Stream := TBlobStream.Create(FieldByName('Doc')
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;
end;
Doc_ole.CreateObjectFromFile
(OpenDialog1.FileName,False);
Doc_ole.Run;{Doc_ole为ToleContainer构件名}
end;
end;
procedure TsampleForm.OpenDOCClick(Sender: TObject);
var
MemSize: Integer;
Buffer: PChar;
MyFile: TFileStream;
Stream: TBlobStream;
begin
OpenDialog1.Filter:='WORD文档(*.DOC)|*.DOC'
;{从对话窗选择文件}
if OpenDialog1.Execute then begin
MyFile:=TFileStream.Create
(OpenDialog1.FileName,fmOpenRead);
with table1 do {‘table1’为含BLOB字段的表名}
begin
Open;
Edit;
Stream := TBlobStream.Create(FieldByName('Doc')
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;
end;
Doc_ole.CreateObjectFromFile
(OpenDialog1.FileName,False);
Doc_ole.Run;{Doc_ole为ToleContainer构件名}
end;
end;