Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » Community » Newbie corner » SQL query generator
SQL query generator [message #32948] Fri, 24 June 2011 14:07 Go to previous message
jibe is currently offline  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 Smile

But when I change to this
	where = ~field == ~val;

Or this
	where = NAME ~cond ~val;

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

 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Converting HTML to "normal" text
Next Topic: Foreign Languages - For FileSel, PromptOK, and other
Goto Forum:
  


Current Time: Sun Apr 28 14:51:11 CEST 2024

Total time taken to generate the page: 0.09584 seconds