Solved

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

Posted on 1999-01-06
7
1,006 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
Comment Utility
I was halted!
0
 
LVL 12

Expert Comment

by:rwilson032697
Comment Utility
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
Comment Utility
euhm, why don't you use just field....AsString := richtedit1.lines.text; ?
0
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 

Author Comment

by:w_iceberg
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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…
Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

728 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now