Page 1 of 1

TMyQuery, cannot find any fields ...TField.Origin issue ?

Posted: Mon 02 Aug 2010 16:37
by Pete B
Hi
I'm using Delphi 2009 / MyDAC 5.90.0.56 in an IntraWeb 10 project.
I have one TMyQuery with SQL.Text which queries 2 tables through a single inner join. The StrictUpdate property has to be false of course during insert/update due more than one row affected and there are no problems querying both tables through the one TMyQuery except ...

All is OK until I want to use the TMyQuery fields editor. I can declare fields from either table OK and their properties appear in the object inspector eg. I want to set DisplayFormat. When I run the project with a TField(s) declared from either table, it fails with an EDatabase Error : Field (abc123 or whatever) Not Found.

The origin property of each field is empty (I thought MyDAC completed this automatically ?) but even if I try any combination for these eg. databasename.tablename.fieldname or just tablename.fieldname, I can't run the project with any TFields declared ... I'm just told they are not found.

This is probably really simple but at the moment I can't see what's wrong. Please can anyone help with this ? ... thanks

Pete B.

Posted: Tue 03 Aug 2010 08:38
by Dimon
To add fields to the dataset perform the following steps:
- Drop the TMyQuery component on a form.
- Set the SQL property.
- Right-click on the component to open pop-up menu.
- Click on the "Fields Editor..." menu.
- Right-click in the open window to call the pop-up menu.
- Select "Add all fields" item.

Set the TMyDataSetOptions.FieldsOrigin property to True to fill the Origin property of TField objects with the appropriate value automatically.

Posted: Tue 03 Aug 2010 09:54
by Pete B
Hi Dimon, thanks for the reply but I'm afraid it doesn't help. I know that fields are added using the fields editor, this has already been done. I mentioned in my previous post that the fields are declared in the Delphi unit and that their properties are visible in the Object Inspector which would imply that I have already used the fields editor. The issue may well still be simple but I think it is a little deeper than that :wink:
The TMyQuery.Options.Origin property is True but I don't get the origin property of any of my fields automatically put in place ... as I mentioned before, I thought this should happen too.
Do you have any other ideas please :?:

cheers

Pete B.

Posted: Tue 03 Aug 2010 12:17
by Dimon
I can not reproduce the problem. Please try to compose a small sample to demonstrate the problem and send it to dmitryg*devart*com.

Posted: Fri 06 Aug 2010 10:21
by Pete B
Well I did say I thought the answer might be simple :oops:
The TMyQuery.Options.Origin property is True but I don't get the origin property of any of my fields automatically put in place ... as I mentioned before, I thought this should happen too.
... perhaps unsurprisingly, all you have to do here is also ensure that the Active property is True at design time :roll:

As for the EDatabaseError, well as you mentioned ALL fields should be included, NOT just the ones needing property changes.

Now it's fixed but then I suppose it could be argued it wasn't really a problem :wink:

cheers

Pete B

Posted: Fri 06 Aug 2010 10:34
by Dimon
If any other questions come up, please contact me.