Page 1 of 1

Edit a record on a result dataset

Posted: Tue 28 Aug 2007 05:56
by Willo
hi;

i have this code to change a field's value on a result dataset from a query:

Qcartas.First;
While not Qcartas.Eof do
begin
Qcartas.Edit;
Qcartas.FieldByName('re_record').AsString := 'S';
Qcartas.Post;
Qcartas.Next;
end;

But... there is a string field on the result dataset that sometimes contains a comma (,) so, i got an syntax error from the Mysql server.

That is because the update sentence generated by Qcartas.Post, uses all the fields on the where clause, so the one with the comma causes the error.

Is there a way to solve it or i have to rewrite the entire rutine?

TIA

Posted: Tue 28 Aug 2007 08:14
by Antaeus
Try to set the Qcartas.Options.QuoteNames to True before editing data.

Posted: Tue 28 Aug 2007 15:34
by Willo
Antaeus wrote:Try to set the Qcartas.Options.QuoteNames to True before editing data.
It didnt work, the help says:

QuoteNames If True TCustomMyDataSet quotes all field names in autogenerated SQL statements such as update SQL.

So, with QuoteNames set to false; the error i got is for the records with string fields that contains commas only.

But with QuoteNames set to true, the error MySQL server sends is because the TMyQuery generates que SQL sentence with all the fieldnames quoted, like:
...where `sl_tipo`= '3878' and `sl_nom`='INTEGRACION UNICA'


Any ideas?

Posted: Wed 29 Aug 2007 11:27
by Antaeus
Could you send me a complete small sample at evgeniyD*crlab*com to demonstrate the problem? Please also include script to create and fill table used in the sample.

Also supply me the following information:
- exact version of MyDAC. You can see it in the About sheet of TMyConnection Editor;
- exact version of your IDE (including personality name for Delphi 2005, and BDS 2006);
- exact version of MySQL server and MySQL client. You can see it in the Info sheet of TMyConnection Editor.