with ADOQuery1 do
begin
Edit;
FieldByName('doc').AsString := RichEdit1.Text;
Post;
end;
function blobcontenttostring(const filename: string):string;
begin
with tfilestream.create(filename,fmopenread) do
try
setlength(Result,size);
read(Pointer(Result)^,size);
finally
free;
end;
end;
//保存字段
var
sFileName : String;
begin
RichEdit1.Font.Color := ClRed;
RichEdit1.Lines.SaveToFile('C:\aaa.rtf');
if (opendialog1.execute) then
begin
sFileName:=OpenDialog1.FileName;
adoquery1.edit;
adoquery1.fieldbyname('doc').asstring:=Blobcontenttostring(sFileName);
adoquery1.post;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var
MS: TStream;
begin
ADOQuery1.First;
with ADOQuery1 do
MS:=CreateBlobStream
(FieldbyName('Doc'),bmRead);
RichEdit2.Lines.LoadFromStream(MS);
MS.Free;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
ADOQuery1.Next;
end;