BaseTableName for SQL Server fields

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
yeohray
Posts: 56
Joined: Mon 26 Mar 2007 01:25

BaseTableName for SQL Server fields

Post by yeohray » Sun 05 Aug 2012 15:58

In the OLEDBAccessUni unit, I see that there is a TOLEDBFieldDesc class that contains some interesting details about the returned fields. How can I access this data? I tried the following:

if qryMain.GetFieldDesc(qryMain.Fields[0].FieldName) is TOLEDBFieldDesc then
begin
ShowMessage(TOLEDBFieldDesc(qryMain.Fields[1]).BaseTableName);
end;

but the details are always empty.

Thanks in advance.

AndreyZ

Re: BaseTableName for SQL Server fields

Post by AndreyZ » Mon 06 Aug 2012 08:47

Hello,

You cast TField to TOLEDBFieldDesc, it is incorrect. You should use the following code:

Code: Select all

if qryMain.GetFieldDesc(qryMain.Fields[0].FieldName) is TOLEDBFieldDesc then
  ShowMessage(TOLEDBFieldDesc(qryMain.GetFieldDesc(qryMain.Fields[0].FieldName)).BaseTableName);

yeohray
Posts: 56
Joined: Mon 26 Mar 2007 01:25

Re: BaseTableName for SQL Server fields

Post by yeohray » Mon 06 Aug 2012 15:50

Thanks, that was indeed a mistake on my part. However, I am still unable to get any values from the BaseTableName property.

Are there any conditions where Unidac will not retrieve these properties? My app is a multi-threaded app, and the connection components are placed on a data module, and server-specific data modules are inherited from this base data module e.g. a SQL Server data module will inherit from the base data module containing a TUniConnection and TUniQuery, with the addition of the SQL Server specific provider.

Thanks in advance.

AndreyZ

Re: BaseTableName for SQL Server fields

Post by AndreyZ » Tue 07 Aug 2012 08:32

The BaseTableName property is filled with a value that is returned from SQL Server. If it is blank, it means that SQL Server doesn't return or cannot return the correct table name for the used SQL statement.

Post Reply