Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 3 of 3 total
Thread Passing Memo.Lines.Text to a Query
Wed, Nov 21 2007 11:43 AMPermanent Link

adam
I am creating an SQL UPDATE Statement in the form:

UPDATE TableName SET
Field1 = 'Value1',
...

WHERE ID = 1

;

I am running code to substitute Field-names for Field1, Field2, etc & to substitute
Field-values for Value1, Value2. Doing this allows me to run UPDATEs with canned data.

When I try to substitute in the data from a Memo field I hit a double problem ...

1. The memo may contain apostrophies (i.e. "This was John's idea")
2. If it is multiline the memo contains end-of-line chars.

Therefore I can't just call:

Value1 := '''' + Memo1.Lines.Text + '''';

Is there a function hidden somewhere in the VCL or DBISAMlb that can manage this
conversion for me??

i.e. a function in the form:

MemoToStr(aStringList : TStringList) : String;

... or otherwise what is the best plan for posting memo data via UPDATE statements?

adam

Wed, Nov 21 2007 12:10 PMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

adam


The embedded quotes can be handled by using QuotedStr rather than adding quotes yourself.

The CRLF pairs are a fraction more difficult -
1. figure out what to replace them with and
a) use the TStrings.DelimitedText property
or
b) use StringReplace to change them

Roy Lambert
Fri, Nov 23 2007 12:50 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Adam,

<< Is there a function hidden somewhere in the VCL or DBISAMlb that can
manage this conversion for me?? >>

Use the TDBISAMEngine.QuotedSQLStr method:

http://www.elevatesoft.com/dbisam4d7_tdbisamengine_quotedsqlstr.htm

--
Tim Young
Elevate Software
www.elevatesoft.com

Image