Maybe a suggestion

Discussion of open issues, suggestions and bugs regarding MyDAC (Data Access Components for MySQL) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
jalin
Posts: 23
Joined: Tue 18 Mar 2008 14:45

Maybe a suggestion

Post by jalin » Fri 16 May 2008 00:38

I was trying to find the way to create dinamically the select statement of a SQL. Is there a way to create the SELECT statement using something like ADDWHERE or ORDERBY methods?

Thanks in advance
Jalin

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Fri 16 May 2008 12:10

To create a query dynamically you can use the following TCustomMyDataSet methods:
AddWhere, DeleteWhere, GetOrderBy, SetOrderBy, FilterSQL.
You can find more detailed information about these methods in the MyDAC help.

jalin
Posts: 23
Joined: Tue 18 Mar 2008 14:45

Post by jalin » Sat 17 May 2008 19:46

These methods modify the SET ORDER BY and WHERE clauses but not the SELECT clause

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Wed 21 May 2008 09:51

You should use the TCustomMyDataSet.SQL property and set the SELECT statement like this:

Code: Select all

MyQeury.SQL.Text := 'SELECT * FROM tablename';

jalin
Posts: 23
Joined: Tue 18 Mar 2008 14:45

Post by jalin » Wed 21 May 2008 12:54

Yes of course, this is the common way to do it and many times you can use the ADD method SQL.ADD('SELECT....´) but I was looking something more dinamic. Maybe Im not explaining my idea.

Dimon
Devart Team
Posts: 2910
Joined: Mon 05 Mar 2007 16:32

Post by Dimon » Wed 21 May 2008 13:34

Could you explain your idea in more details?

Post Reply