用olecontainer显示的话,不用把Doc转化为rtf,下面是一个例子,若你非要用
richedit来显示的话,我得再写一段程序把word.doc转化为rtf.
procedure savetodb;
var
st:TStringStream;
begin
st := tstringstream.create('');
olecontainer1.createfromfile('c:/xxx.doc',true);//也可以是..('xx.doc',false);
olecontainer1.savetostream(st);
query1.sql.text := 'insert into TableX Doc_field values
oc';
query1.parambyname('Doc').asblob := st.datastring;
query1.execsql;
st.free;
end;
procedure loadfromdb;
var
st:TStringStream;
blobsteam:Tblobstream;
begin
st:= tstringstream.create('');
blobStream := TBlobStream.Create(Table1Doc, bmRead);
if BlobStream.Size = 0 then begin
BlobStream.Free;
Exit;
end;
st.CopyFrom(BlobStream, BlobStream.Size);
st.position:=0;//可能直接
olecontainer1.loadfromstream(st);
//可能直接blobstream.position:=0,olecontainer1.loadfromstream(blobstream);也行
st.free;
BlobStream.Free;
end;