3

I got an ADO Database with a table named t_codemeaning, below are the table structure :

t_codemeaning
  codemenaing_code AS Text
  codemenaing_title AS Text
  codemenaing_description AS Text

I add all of table in my ADOQuery1.

I click a button with this Delphi script:

ADOQuery1.edit;
ADOQuery1codemeaning_title.value := edit1.text;  
ADOQuery1codemeaning_description.value := memo1.lines.text;  
ADOQuery1.post;

When I add the single line in memo, then every thing is Fine.

But when I add lot of multiple line of text in memo1, then it shows me an error :

Multiple-step operation generated errors. Check each status value.

How to fix this ?


My last progress, I made a new string variable aValue and add the memo1.lines.text into it :

  aValue:=memo1.lines.text;
  aValue := StringReplace(StringReplace(aValue, '#10', '', [rfReplaceAll]), '#13', '', [rfReplaceAll]);

And I change the script for ADOQuery1codemeaning_description.value .... into :

ADOQuery1codemeaning_description.value := aValue;  

still got the same error...

TLama
  • 75,147
  • 17
  • 214
  • 392
Galvion
  • 1,353
  • 7
  • 23
  • 35
  • 3
    This is caused by the "CRLF" line endings in your code. When you assign the lines it gets encoded as one string. You need to escape the line endings in the format expected by the ADO machine. In other words, the multi-line memo string is passing invalid characters to the ADO. –  Feb 14 '13 at 21:25
  • does "CRLF" refer to #13#10 ? – Galvion Feb 14 '13 at 21:41
  • aValue:=memo1.lines.text; aValue := StringReplace(StringReplace(aValue, '#10', '', [rfReplaceAll]), '#13', '', [rfReplaceAll]); – Galvion Feb 14 '13 at 21:47
  • Yes. On Linux it is just LF or #10 but windows uses the #13#10 but many programs in windows also understand plain #10. Double check the format expected by the ADO function. At best do exactly what you specified in previous commect yes! That should work. Maybe replace with the space character? –  Feb 14 '13 at 21:48
  • And still got the same error.... – Galvion Feb 14 '13 at 21:48
  • Do not put the #13 inside the string. I mean the parameter to the function, just put #13#10 as the parameter, and do not put it in quotes. As for StringReplace you can call it twice with #10 as well is more portable code or just do it for #13#10 once which is fine for windows. –  Feb 14 '13 at 21:49
  • 3
    What DB you use? The description field probably needs to be a type of `Memo`. and your persistent `ADOQuery1codemeaning_description` field type should be `ftMemo` not `ftString`. There is no need to escape anything. – kobik Feb 14 '13 at 21:52
  • aValue:=mmDescription1.lines.text; aValue := StringReplace(StringReplace(aValue, #10, ' ', [rfReplaceAll]), #13, ' ', [rfReplaceAll]); –  Feb 14 '13 at 21:53
  • I use ADO / Access Database Object (.MDB) with JET OLEDB connection – Galvion Feb 14 '13 at 21:53
  • ahh... Kobik, you are right.... the mistake is at the type of the table structure for the field : codemenaing_description AS Text. It should be defined as codemenaing_description AS Memo.... Done all of the matter is cleared :) Do you mind to post your answer ? – Galvion Feb 14 '13 at 21:58

1 Answers1

9

Define your description field as Memo in the DB (instead of Text), and then remove all your persistent fields from ADOQuery1, and add them again so that ADOQuery1codemeaning_description type is ftMemo.

No need to escape or replace CRLF.

kobik
  • 21,001
  • 4
  • 61
  • 121