Solved

How to insert a RichEdit content to Ms SQL Server's  TEXT column

Posted on 1999-01-06
7
1,092 Views
Last Modified: 2013-11-22
I want to display user's input data in rich text format ,thus i use TRichEdit control to fulfill it .User inputs the contents to the TRichEdit Control.I save them to Ms SQL Server database(a column whose data type is text) and then display the contents in TRichEdit control when user needs it.

I have read the RichEdit control's content to a string using TMemoryStream.but it seems that it's impossible to save to the TEXT COLUMN.

How can i do?

please mail me if you have ideas!

thanks
0
Comment
Question by:w_iceberg
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 

Author Comment

by:w_iceberg
ID: 1354817
I was halted!
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1354818
Alright - this is a silly question - why not use a memory stream to go the other way?

I assume you go .Loadfromstream? Then use SaveToStream to fill the TMemoryStream with the RTF and move its contents to the TEXT field in the reverse manner?

Cheers,

Raymond.

(dibs on the answer if this is it :-)

0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1354819
euhm, why don't you use just field....AsString := richtedit1.lines.text; ?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:w_iceberg
ID: 1354820
Dear rwilson:
  I have not tried the way as you said.obviously it's useless for me because I use DB-library to communicate with MS SQL Server(No querys and tables are availble, only Storedprocs and SQLs are avaible).But thanks a lot!
 as I have tried when I use plain text it's ok.I guess the reason must be the format of RichText.
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 1354821
w_iceberg,

I tried this :

unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, Buttons, ComCtrls;

type
  TForm1 = class(TForm)
    RichEdit1: TRichEdit;
    BitBtn1: TBitBtn;
    Memo1: TMemo;
    procedure BitBtn1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
 Memo1.lines.text := richedit1.lines.Text;
end;

end.

It gives no problems.

Can you specify your problem more?

Thanks, Zif.
0
 
LVL 12

Expert Comment

by:rwilson032697
ID: 1354822
w_iceberg: The RTF format is also just plain text (in that it is ASCII) there should be no real problems treating it is text for the DB field...

Raymond.
0
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 200 total points
ID: 1354823
w_iceberg:

here's another shot. When you go to save the edited contents of the Richedit save them to a temporary file like this:

RichEdit1.PlainText := False;
RichEdit1.lines.SaveToFile('tmp.rtf');

You now has a file that is a text file containing the rtf from the control. You should be able to easily put this into your text field in the database.

Cheers,

Raymond.

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question