Solved

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

Posted on 1999-01-06
7
1,122 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
Michael from AdRem Software explains how to view the most utilized and worst performing nodes in your network, by accessing the Top Charts view in NetCrunch network monitor (https://www.adremsoft.com/). Top Charts is a view in which you can set seve…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses
Course of the Month9 days, 19 hours left to enroll

623 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