Solved

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

Posted on 1999-01-06
7
1,060 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
  • 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
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 

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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone 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

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

808 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