Home » Community » Newbie corner » SQL query generator
SQL query generator [message #32948] |
Fri, 24 June 2011 14:07 |
|
jibe
Messages: 294 Registered: February 2007 Location: France
|
Experienced Member |
|
|
Hi,
I want to make a kind of query generator. I'm trying this :
In a dialog box, I have :
- a dropdown list with the fields of my table,
- another dropdown list with possible relations (==, !=, <, <= etc.)
- an EditString where to type the desired value.
This will generate SQL queries like :
SELECT * from MYTABLE where (field) (relation) (value)
ie : SELECT * FROM CLIENTS WHERE NAME == TOTO
I tried this :
void MyApp::Query()
{
String field, cond, val;
SqlBool where;
field = dialog.dl_field.GetValue();
cond = dialog.dl_cond.GetValue();
val = dialog.ed_cond.GetData();
where = NAME == ~val;
mytable.Query(where);
}
This is working well
But when I change to this
Or this
It's no more working...
I tried many other things, ie grouping field, cond and val in a single String, but I cannot find a way to have it working.
How can I do ? I want to find a way to choose at runtime the complete "where" condition...
[Updated on: Fri, 24 June 2011 14:12] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Thu Jun 06 07:25:34 CEST 2024
Total time taken to generate the page: 0.01844 seconds
|