How to add multiple lines from a TMemo component to a MS Access database?

delphi, delphi-2010, memo, ms-access, tadoquery

Solution

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`.

Problem

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...

Original source