?
Solved

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

Posted on 1999-01-06
7
Medium Priority
?
1,171 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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 400 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

718 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