richedit读写image字段

来源:http://hi.baidu.com/%D6%D0%CC%EC%B4%F3%C3%D7/blog/item/31ea821fdbc05467f724e41e.html

procedure TForm2.Button1Click(Sender: TObject);
var

    ms:tmemorystream;
begin
    ms:=tmemorystream.Create;
    richedit1.Lines.SaveToStream(ms);
    adotable1.Append;
    tblobfield(adotable1.FieldByName('11')).LoadFromStream(ms);
    adotable1.Post;
end;

读取用dbrichedit

 
来源: http://topic.csdn.net/u/20101021/18/f3e9f81c-837b-4c19-9d10-c22d7104a257.html

【保存方法】

var
  Str: string;
  temStream: TMemoryStream;
begin
  temStream := TMemoryStream.Create;
  RichEdit1.Lines.SaveToStream(temStream);
  str := 'select * from Table1';
  AdoQuery1.Close;
  AdoQuery1.SQL.Clear;
  AdoQuery1.SQL.Add(str);
  AdoQuery1.Open;
  AdoQuery1.Append;
  AdoQuery1.FieldByName('ID').AsInteger:= 3;
  TBlobField(AdoQuery1.FieldByName('RichEditText')).LoadFromStream(temStream);
  AdoQuery1.Post;
  temStream.Free;

 

【读取方法】

var
  Str: string;
  temStream: TMemoryStream;
begin
  temStream := TMemoryStream.Create;
  str := 'select * from Table1 ';
  AdoQuery1.Close;
  AdoQuery1.SQL.Clear;
  AdoQuery1.SQL.Add(str);
  AdoQuery1.Open;
  TBlobField(AdoQuery1.FieldByName('RichEditText')).SaveToStream(temStream);
  temStream.Seek(0,0);
  RichEdit1.Lines.LoadFromStream(temStream);
  temStream.Free;

你可能感兴趣的:(c,image,String,table,2010)