#42522 Unknown column saldo in field list

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
cybsistemas
Posts: 118
Joined: Mon 12 Sep 2005 17:31
Location: Argentina

#42522 Unknown column saldo in field list

Post by cybsistemas » Fri 08 Feb 2008 00:30

MyQuery1.SQL.Text := 'select id,name,0.00 as saldo from Customers';
MyQuery1.Execute;

While not MyQuery1.Eof do

Begin
MyQuery1.Edit;
MyQuery1.FieldByName ('saldo').AsFloat := 20;
MyQuery1.Next;
End;

The version 5.10 it works correctly.
The version 5.20 the following error
//#42522 Unknown column saldo in field list

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Tue 19 Feb 2008 12:59

Verify if the table 'Customers' has field 'saldo'. If it has not, then the error arises because on assigning a value to this field TMyQuery tries to save it in the database.
If you want to use this field as local, set the TMyQuery.Options.SetFieldsReadOnly property to True, and then for 'saldo' field the ReadOnly property to False.
Use MyDAC version 5.20.1.14.

cybsistemas
Posts: 118
Joined: Mon 12 Sep 2005 17:31
Location: Argentina

Post by cybsistemas » Thu 21 Feb 2008 21:20

I did that, but you tell me that the field cannot get modified.
I pay out the field not this at the table, it is a virtual field.

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Fri 22 Feb 2008 15:03

You should use the following code:

Code: Select all

 MyQuery1.Options.SetFieldsReadOnly := True;
 MyQuery1.FieldByName('saldo').ReadOnly := False;
If you set the SetFieldsReadOnly property to True then 'saldo' field won't be included to queries of updating table. As for this it is set as read only.
In order to use it as a variable virtual field set ReadOnly to false.

cybsistemas
Posts: 118
Joined: Mon 12 Sep 2005 17:31
Location: Argentina

Post by cybsistemas » Fri 22 Feb 2008 23:41

Thanks

Post Reply