[Webinar] Streamline your web hosting managementRegister Today


multiple database recordsets -- mdi app

Posted on 2000-01-02
Medium Priority
Last Modified: 2013-11-20
Is it OK to have several instances of the same recordsets to perform different purposes in a database app?

Here's what I'm trying to do:

1.  Show all info 1 record at a time (from several related tables) in a view

2.  Allow users to browse each separate table & set filters to find various sets of records

SHould I create different recordsets in the document & give them to each view as they are needed?  SInce this is an MDI app, users can switch back & forth between windows at any time.

Also, does anyone have any generic filter-setting code?  Right now I have a hard-coded dialog for each table.  It seems redundant.  I'm wondering if there is a generic class that could read a table structure & present it to users for filtering.


Question by:veronicas

Expert Comment

ID: 2319280
have you tried using m_strFilter before?

Expert Comment

ID: 2319281
What Kind of Database Are you Using?

Expert Comment

ID: 2319404
There is nothing wrong as far as U or any body using don't add or delete records to the table of which U are creating multiple instances.

U need not have an associated class for each filter U can query using SELCT statement like one below
CRecordset rs;
rs.Open("SELECT field1, field2, field3 FROM MyTable WHERE field1 > 100");

for which even U can use Filter to set and reopen the table or requery it and choose only selected fields of the table

Hope this helps

Author Comment

ID: 2321431
The class I was talking about for the filter is one that will create a screen for the user with the various field names and allow them to create a filter string through a GUI.  I used to do this back in the days with Clipper, but I'm dating myself.  The code will read the field names, create a dialog for the users and allow them to enter values for selected fields.

Anyway, back to the original question.  In my document, I've got 3 recordsets, one for each table.  However, since the user could open a view to see the whole table, and possibly one to see a selected set of records, or possibly go back to the main screen and see a snapshot of the fields from the 3 tables all on one screen, I was wondering if I should also hold a temp recordset & give that out from the document as needed.

Accepted Solution

dhodge earned 280 total points
ID: 2327089
Yes you can do what you require, you can simply store the recordset and the filter in each doc, and handle the view updating as normal.

As for the filter you could create a totally generic sollution using the dao/ado methods to get field names and types.  I would be quite an interesting task.  Enumerate the fields for each table you want to allow viewing on, slap them onto a grid or other GUI and let the user enter suitable values.  Then contruct the SQL and put it into the m_strFilter.

Bosh, SQL just do it!

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses
Course of the Month11 days, 11 hours left to enroll

640 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question