what would be the best way to create a Query builder in delphi?
I have devexpress quantum grid, so I can display data easily.
what would be the best way to create a Query builder in delphi?
I have devexpress quantum grid, so I can display data easily.
It really depends on how complicated and intuitive you want the query builder to be. I wrote a cheap and cheerful SQL Query Form into an app in Delphi 5, using a TMemo component only allowing the Select commands to be run. There are various sql queries you can run to gather information from SQL on schema so you can get the tables and fields in a database and populate a treeview component or something like that.
What you mean by "Query Builder"? do you need a visual component for the end-user to build SQL queries or some kind of programmatic solution? And what means "the best way"? Can you list the considered ways to cope with this task?
Why write your own when there already is a solution ready to be compiled into your application? The folks at fast-reports have a nice query builder that includes complete source. There also is an open source version, although you would have to update it yourself to support Unicode.
At least as of a few years ago, best query building component for Delphi was "Simple Query", an inexpensive component from a Russian toolmaker. Great component, features are much deeper and better thought out than they might at first appear. I used it with good success to integrate with data in QuantumGrid. (Since Simple Query merely generates an SQL string there isn't really much to integrate that way. But I did also tailor the visual appearance so it looked consistent with the QG.) http://devtools.korzh.com/query-builder-delphi/
Note that the interface for Simple Query (and their "Easy Query" .NET component) is geared towards making it simple for users to generate valid searches without having any concept of tables, joins, or SQL. Takes a bit of foresight by developer to configure interface perfectly that way, but it's a nice feature. Also can be used as "full strength" solution for database experts.
Also, I assume you're aware that QG has its own integrated visual query system. I think my main problem with that was that it was mostly geared towards filtering the existing dataset, but in any case Simple Query was far more flexible.
Another thing, under the covers Simple Query has a number of objects that are used to generate the final SQL string, analogous to the code you posted and are asking about. Main purpose for this was just as intermediate stage between visual description and final output as SQL.
I have used Active Query Builder (http://www.activequerybuilder.com/product_vcl.html) as the UI for users to build queries. It includes an option to match the look and feel of the Dev Express grid, if you buy the source code.