Query flexibility with MFC
Posted on 2003-12-02
I will try to make this as clear as possible. I'm trying to write an MFC application that can receive user input in the form of simple db queries and can return the appropriate records. The tricky thing is that I want the user to be able to write these sql queries as if they have no knowledge of the structure of any Recordsets contained within the application...all they know about is the structure of the db itself. I'm trying to achieve this without defining a particular Recordset for each possible subset of columns that will be retrieved with each query.
MSDN states: For every distinct table, view, or stored procedure you wish to access, you typically define a class derived from CRecordset. (The exception is a database join, in which one recordset represents columns from two or more tables.)
My problem is that a user in this application may use a join or they may not. They may reference every column from 3 different tables in their query, or they may just need one column from one table. I'm trying to make this as free and simple as possible for the end user. At first, when attempting to do this, the user sql statements were required to be bloated and contain every column in their select statements, and contain all possible join statement in a given recordset in order for the queries to be successful. I'm trying to avoid this.
If this cannot be achieved using Recordsets, but can with another datastructure...or if it is possible using Recordsets...or if you have no idea what I'm talking about, your reponse would be greatly appreciated.