Page 1 of 1

cannot update, <TOraQuery> is not owned by <TOraSession>.

Posted: Tue 23 Feb 2010 12:31
by albourgz
BCB 2009, ODAC 6.90.0.54.
I have a big application consisting of:
1. 1 TOraSession OurDB in a datamodule FDM,
2. Lots of (read-only) master-child forms, where master query is named QDict and child Query is QDictDet, all linked to the same TOraSession.
The panels of these forms are regrouped into tabs into another form.
3. A form with an editable TDBGrid based on a TTable (linked to the TOraSession OurDB).

In some circonstances:
When closing form with editable TDBGrid, the following code is executed:

Code: Select all

void __fastcall TFSundays::FormClose(TObject *Sender, TCloseAction &Action)
{
	if (!DBGrid1->ReadOnly)	{
		FDM->OurDB->ApplyUpdates();
		FDM->OurDB->Commit();
		}
    Table1->Close();
    Action=caFree;
}
And when this code is executed, I get (often but not always) an exception:
cannot update, QDictDet is not owned by OurDB.

Problems:
* I have lots of queries named QDictDet, but I don't know which ones he is talking about.
* All forms are inherited from the same master-child where QDictDet is linked in TOraSession AND is ReadOnly.
* I really don't understand: the code asks to perform updates on queries linked to OurDB session. He claims he tries to update a query NOT related to this session. If it is NOT related to the session, he should not try to update. If it is related to the session, the error message should be something else that "query not linked to session".

How can I "debug" to see what is causing this problem? All QDictDet queries are read-only, the only one that is not is a TTable.

Regards,
Alain

Re: cannot update, <TOraQuery> is not owned by <TOraSession>.

Posted: Wed 24 Feb 2010 09:12
by albourgz
albourgz wrote:BCB 2009, ODAC 6.90.0.54.
I have a big application consisting of:
1. 1 TOraSession OurDB in a datamodule FDM,
2. Lots of (read-only) master-child forms, where master TOraQuery is named QDict and child TOraQueryis QDictDet, all linked to the same TOraSession.
The panels of these forms are regrouped into tabs into another form.
3. A form with an editable TDBGrid based on a TTable (linked to the TOraSession OurDB).

In some circonstances:
When closing form with editable TDBGrid, the following code is executed:

Code: Select all

void __fastcall TFSundays::FormClose(TObject *Sender, TCloseAction &Action)
{
	if (!DBGrid1->ReadOnly)	{
		FDM->OurDB->ApplyUpdates();
		FDM->OurDB->Commit();
		}
    Table1->Close();
    Action=caFree;
}
And when this code is executed, I get (often but not always) an exception:
cannot update, QDictDet is not owned by OurDB.

Problems:
* I have lots of queries named QDictDet, but I don't know which ones he is talking about.
* All forms are inherited from the same master-child where QDictDet is linked in TOraSession AND is ReadOnly.
* I really don't understand: the code asks to perform updates on queries linked to OurDB session. He claims he tries to update a query NOT related to this session. If it is NOT related to the session, he should not try to update. If it is related to the session, the error message should be something else that "query not linked to session".

How can I "debug" to see what is causing this problem? All QDictDet queries are read-only, the only object that should be updated is a TTable not named QDictDet.

Regards,
Alain

Posted: Wed 24 Feb 2010 12:04
by Challenger
Please try to execute the following code before calling the ApplyUpdates method:

Code: Select all

  for (int i = 0; i DataSetCount; i++) {
    if (OurDB->DataSets[i]->Connection  != OurDB)
       ShowMessage(OurDB->DataSets[i]->Name);

Posted: Wed 24 Feb 2010 12:34
by albourgz
Cannot compile this: Connection is not a member of TDataSet.

Posted: Thu 25 Feb 2010 11:31
by Challenger
Please cast OurDB->DataSets to TCustomDADataSet class.

Posted: Fri 19 Mar 2010 14:09
by albourgz
I have the name of the form (FUnplannedStops).
However, on this form,
* the dataset is read only,
* the dataset holds the statement select sysdate from dual,
* the dataset is displayed in a grid that is behind a TCppWebBrowser component , so is unvisible,
* the dataset is not linked to any TOraSession,
* I am even not sure this dataset is opened.

I linked the dataset to the TOraSession, I will see if it works.