Page 1 of 1
Ambiguous column name error
Posted: Thu 24 Mar 2011 16:42
by brace
In a working application I tired to set a master detail relationship between 2 datasets (because I need to use this relationship in a report that I do with Report Builder), my application doesn't need this relaionship but it won't harm.
I have Master and Detail TMSQuery.
I set (at design time)
Code: Select all
Detail.MasterSource := Master
Detail.MasterField := Master_ID
Detail.DetailField := Master_ID
As I open the datasets I have AMBIGUOUS COLUMN NAME Master_ID. Please note that in the 2 queries Master_ID field appears only once. So why do I have this error?
There was an Order by Master_ID in the Detail query, but I remoevd it.
Posted: Thu 24 Mar 2011 17:08
by brace
I forgot to tell I am using SDAC 5.0.0.3.
Posted: Fri 25 Mar 2011 09:35
by AndreyZ
Hello,
To solve the problem, you should set the DetailField property in the following way:
Code: Select all
Detail.DetailField := DetailTableName.Master_ID
If it doesn't help, please specify the SQL code you are using in both queries.
Posted: Fri 25 Mar 2011 10:25
by brace
I tried as you suggested but still nothing.
This is the sql of the Detail table. I create the master/Detail relationship on the ID_ATTIVITA field
Code: Select all
SELECT
EDE.ID_EVENTO,
EDE.ID_ATTIVITA,
EA.NRO_RIGA AS TASK_NO
FROM
EVA_DOMANDE_EVENTO EDE
LEFT OUTER JOIN EVA_ATTIVITA EA ON EDE.ID_ATTIVITA = EA.ID_ATTIVITA
WHERE
EDE.ID_EVENTO = :ID_EVENTO
ORDER BY
EDE.ID_ATTIVITA, EDE.NRO_RIGA
this is the query, the ambiguity is removed if I remove the JOIN.
I have the error on ID_ATTIVITA fileld, since that field is mentioned also in the join this causes a problem... How to solve?
Posted: Fri 25 Mar 2011 14:14
by AndreyZ
I used your SQL code and changed the DetailFields property to EDE.ID_ATTIVITA. This solved the problem. If it doesn't help you, please try composing a small sample to demonstrate the problem and send it to andreyz*devart*com, including scripts to create the EVA_DOMANDE_EVENTO and EVA_ATTIVITA tables.