Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Odd Error message in tfdquery


This question is answered. Helpful answers available: 1. Correct answers available: 1.


Permlink Replies: 10 - Last Post: Apr 12, 2018 9:09 AM Last Post By: Barry Wood Threads: [ Previous | Next ]
Barry Wood

Posts: 73
Registered: 9/3/01
Odd Error message in tfdquery  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 9, 2018 1:45 AM
Hi
I'm making several changes to MSSQL tables via using and fdquery (called 'qryReplacePlayer), one delete and several updates, similar to this:
SQL.Clear;
SQL.Add('DELETE FROM tSeniorsTeams WHERE MatchID = :pMatchID AND PlayerA = :pPlayerID');
ParamByName( 'pMatchID' ).AsInteger := iMatchID;
ParamByName( 'pPlayerID' ).AsInteger := iReplacementID;
ExecSQL;
These all work fine and the changes get made in the tables.

At the end of the changes I clear the query, add the original query (which is a simple 'select * from xxx', and set Active:= True;

However, (looking via the debugger) as soon as this line is executed I get an error message 'qryReplacePlayer: Field 'TeamComments' not found.' This field doesn't exist in any of the tables the query is working with, but it does exists in a different table and a view from that table. So how can I be getting an error on activating a query that doesn't have anything to do with a field that exists in two other table/views?

I've replaced the tfdquery, in case something was hanging around in the background.

Any thoughts would be helpful.
Lajos Juhasz

Posts: 801
Registered: 3/14/14
Re: Odd Error message in tfdquery  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 9, 2018 2:09 AM   in response to: Barry Wood in response to: Barry Wood
Barry Wood wrote:

Hi
I'm making several changes to MSSQL tables via using and fdquery
(called 'qryReplacePlayer), one delete and several updates, similar
to this: SQL.Clear; SQL.Add('DELETE FROM
tSeniorsTeams WHERE MatchID = :pMatchID AND PlayerA = :pPlayerID');
ParamByName( 'pMatchID' ).AsInteger := iMatchID;
ParamByName( 'pPlayerID' ).AsInteger := iReplacementID;
ExecSQL; These all work fine and the changes get made in the tables.

At the end of the changes I clear the query, add the original query
(which is a simple 'select * from xxx', and set Active:= True;

However, (looking via the debugger) as soon as this line is executed
I get an error message 'qryReplacePlayer: Field 'TeamComments' not
found.' This field doesn't exist in any of the tables the query is
working with, but it does exists in a different table and a view from
that table. So how can I be getting an error on activating a query
that doesn't have anything to do with a field that exists in two
other table/views?

I've replaced the tfdquery, in case something was hanging around in
the background.

Any thoughts would be helpful.

You must have had added that field to the query, the field list is not
used in ExecSQL so there is no error message. Double click the query
and delete the created fields.
Barry Wood

Posts: 73
Registered: 9/3/01
Re: Odd Error message in tfdquery  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 9, 2018 3:50 AM   in response to: Lajos Juhasz in response to: Lajos Juhasz
Hi

No that's not it. There were no fields created in the query, and like I said I deleted the original query (just in case) and used a new one. Just added a simple select in it and didn't create any fields.

You must have had added that field to the query, the field list is not
used in ExecSQL so there is no error message. Double click the query
and delete the created fields.
Robert Triest

Posts: 687
Registered: 3/24/05
Re: Odd Error message in tfdquery  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 9, 2018 4:03 AM   in response to: Barry Wood in response to: Barry Wood
Maybe Fields declared in your DBGrid?
Barry Wood

Posts: 73
Registered: 9/3/01
Re: Odd Error message in tfdquery  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 9, 2018 5:52 AM   in response to: Robert Triest in response to: Robert Triest
Hi
There isn't a dbgrid component on either form I'm using. I do have other forms where I have a dbgrid which shows the field TeamComments, but they are not connected in any way to the forms I am using whilst getting this error, nor in anyway connected to the tfdquery I am using.

Robert Triest wrote:
Maybe Fields declared in your DBGrid?
Robert Triest

Posts: 687
Registered: 3/24/05
Re: Odd Error message in tfdquery
Helpful
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 9, 2018 11:58 PM   in response to: Barry Wood in response to: Barry Wood
Open the *.DFM (textfile) of your form in a plain-text editor and look if you see any reference in there..
Lajos Juhasz

Posts: 801
Registered: 3/14/14
Re: Odd Error message in tfdquery  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 9, 2018 4:55 AM   in response to: Barry Wood in response to: Barry Wood
Barry Wood wrote:

Hi

No that's not it. There were no fields created in the query, and like
I said I deleted the original query (just in case) and used a new
one. Just added a simple select in it and didn't create any fields.

You must have had added that field to the query, the field list is
not used in ExecSQL so there is no error message. Double click the
query and delete the created fields.

Than you must have a db-aware component assigned to the query with that
field.
Barry Wood

Posts: 73
Registered: 9/3/01
Re: Odd Error message in tfdquery  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 9, 2018 6:05 AM   in response to: Lajos Juhasz in response to: Lajos Juhasz
Hi
There is a db-aware component (dbgrid & nav) associated with the field 'TeamComments' but not on that form where I am doing the sql changes. Where the field is used/viewed is on an entirely different form which at the time I'm getting this error hasn't even been created.

Than you must have a db-aware component assigned to the query with that
field.
Francisco Arman...

Posts: 11
Registered: 3/3/01
Re: Odd Error message in tfdquery  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 9, 2018 11:46 PM   in response to: Barry Wood in response to: Barry Wood
Barry Wood wrote:
Hi
There is a db-aware component (dbgrid & nav) associated with the field 'TeamComments' but not on that form where I am doing the sql changes. Where the field is used/viewed is on an entirely different form which at the time I'm getting this error hasn't even been created.

Than you must have a db-aware component assigned to the query with that
field.

Hi do you have any DbLookup field on other dataset that could point to a field that is currently in your dataset before setting another sql?
Also check for Calc fields
Barry Wood

Posts: 73
Registered: 9/3/01
Re: Odd Error message in tfdquery  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 10, 2018 1:08 AM   in response to: Francisco Arman... in response to: Francisco Arman...
I don't use dblookup anywhere in the project.

Francisco Armando Dueñas Rodriguez wrote:
Barry Wood wrote:
Hi
There is a db-aware component (dbgrid & nav) associated with the field 'TeamComments' but not on that form where I am doing the sql changes. Where the field is used/viewed is on an entirely different form which at the time I'm getting this error hasn't even been created.

Than you must have a db-aware component assigned to the query with that
field.

Hi do you have any DbLookup field on other dataset that could point to a field that is currently in your dataset before setting another sql?
Also check for Calc fields
Barry Wood

Posts: 73
Registered: 9/3/01
Re: Odd Error message in tfdquery  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 12, 2018 9:09 AM   in response to: Barry Wood in response to: Barry Wood
Hi
My error, I should have checked previous code first! Sorry, but many thanks for all the suggestions. Will try to do better next time.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02