Thread: Odd Error message in tfdquery
 |
This question is answered.
Helpful answers available: 1.
Correct answers available: 1.
|
Posts:
73
Registered:
9/3/01
|
|
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.
|
|
|
Posts:
801
Registered:
3/14/14
|
|
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.
|
|
|
|
Posts:
73
Registered:
9/3/01
|
|
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.
|
|
|
|
Posts:
687
Registered:
3/24/05
|
|
Maybe Fields declared in your DBGrid?
|
|
|
|
Posts:
73
Registered:
9/3/01
|
|
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.
Maybe Fields declared in your DBGrid?
|
|
|
|
Posts:
687
Registered:
3/24/05
|
|
Open the *.DFM (textfile) of your form in a plain-text editor and look if you see any reference in there..
|
|
|
|
Posts:
801
Registered:
3/14/14
|
|
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.
|
|
|
|
Posts:
73
Registered:
9/3/01
|
|
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.
|
|
|
|
Posts:
11
Registered:
3/3/01
|
|
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
|
|
|
|
Posts:
73
Registered:
9/3/01
|
|
I don't use dblookup anywhere in the project.
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
|
|
|
|
Posts:
73
Registered:
9/3/01
|
|
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)
|
|
Connect with Us