Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 206
  • Last Modified:

Datasources

I am creating a component in D1 and I have to refer to either
a TTable or TQuery as the Datasource.  I have coded the following:

If (DataSource.Dataset as TTable) = ..... then
else
If (DataSource.Dataset as TQuery) = ....  then

I have to use that construct several times within the component
and I want to know if there is a simpler way to do it, like by
setting a variable for the (DataSource.Dataset as TTable) or TQuery
part. If so, what type of variable do I need?

Thanks in advance for any help
0
jdthedj
Asked:
jdthedj
1 Solution
 
ZifNabCommented:
Hi jdthedj,

What about this? Make a boolean function of it like :

function IsTable:Boolean;
begin
 if (DataSource.DataSet as TTable) then Result := true
  else Result := false;
end;

In your component, you can call this function :

 if IsTable then ...
  else ....

It's shorter and easier.

Have fun,
c.u. ZifNab;
0
 
jdthedjAuthor Commented:
Thanks ZifNab!!
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now