Page 1 of 1

How get UpdatingTable?

Posted: Sat 19 May 2012 16:41
by sinys
How I can get UpdatingTable which selected automatically?

Code: Select all

// SmartQuery1.UpdatingTable = '' by default
SmartQuery1.SQL.Text := 'select * from customers';
SmartQuery1.Open;
ShowMessage(SmartQuery1.UpdatingTable);  // return empty value
In DOA the same properties return table name (which selected automatically) for update if user not set value for UpdatingTable. How I can get table name for update from my query in ODAC?

Re: How get UpdatingTable?

Posted: Mon 21 May 2012 10:17
by AlexP
Hello,

The UpdatingTable property is set by a user for specifying the table, for which it is necessary to generate UPDATE/INSERT/DELETE/REFRESH SQL queries. If you haven't set this property to SQL, queries for these operations will be generated for the first table specified in the query. To retrieve this table name, you can use the TDBAccessUtils.GetTablesInfo method as follows:

SmartQuery1.SQL.Text := 'select * from customers';
SmartQuery1.Open;
ShowMessage(TDBAccessUtils.GetTablesInfo(TCustomDADataSet(SmartQuery1)).Items[0].TableName);

Re: How get UpdatingTable?

Posted: Mon 21 May 2012 14:35
by sinys
Thank you!

Re: How get UpdatingTable?

Posted: Tue 21 Aug 2012 14:24
by sinys
Can I know the name of the table without "SmartQuery1.Open;" ?

Re: How get UpdatingTable?

Posted: Tue 21 Aug 2012 14:53
by AlexP
hello,

Instead of opening the table, you can call the Prepare method:

Code: Select all

SmartQuery1.SQL.Text := 'select * from customers';
SmartQuery1.Prepare;
ShowMessage(TDBAccessUtils.GetTablesInfo(TCustomDADataSet(SmartQuery1)).Items[0].TableName);