Solved

How to design a VC++/MFC database application

Posted on 1998-10-29
7
216 Views
Last Modified: 2012-05-04
I'm trying to design a telecommunications network planning application. The user will enter network data through various dialogs and, in response to clicking Save on the File menu, it will be stored in a MS Access database. In response to a menu pick, algorithms to perform some analysis on the network will be invoked, and will run as threads. The output will also be stored in database tables, and displayed through reports.
The main application will be built as an AppWizard exe.
I plan on creating an MFC extension DLL containing a class derived from CRecordset for each table in the database. (I'd like to have them in a DLL so that other applications could also use them.) Another DLL will contain the functions to perform the analysis. Only one of these functions will be directly invoked from the main application and it will be a thread function.
My question is, how do I set this up so that both the main application and the thread function in the DLL can access the data? That is, I'd like the CRecordset objects to be created in the main application but available to the thread function. I'm not sure whether the CDatabase object and CRecordset objects should be members of the view or document class in the main application, or should they be defined as globals in the app class.
0
Comment
Question by:ajm411
7 Comments
 

Author Comment

by:ajm411
ID: 1176520
Edited text of question
0
 
LVL 8

Expert Comment

by:MaDdUCK
ID: 1176521
pass pointers between the two...
0
 
LVL 3

Expert Comment

by:danny_pav
ID: 1176522
don't forget to synchronize the use
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
LVL 3

Expert Comment

by:altena
ID: 1176523
This sounds like a real bad idea to me....

Ill explain:
The document/view framework is just a way to look ar data.
It is a bad idea to have all sorts of threads running aroung
accessing this data, (recordsets or something else)
The synchronisation problems will kill the app.

The idea to componentize the app is a good one, but your
components should be based on "objects" in stead of tables.

Think this one over real good, separate the DB-work from the C++ work. and build a good object model FIRST.

Good Luck
0
 

Author Comment

by:ajm411
ID: 1176524
While Altena did a good job of explaining why the design assumption I made was a bad one, not much was offered as far as an alternative.

I had considered the suggestion to use my own objects rather than CRecordset derived objects in the thread function. If I do this, I'm still not sure where to define these objects so that they are accessible by:
1.) the doc class of my main app, where they will be populated from the CRecordset derived objects (the doc class will own the CRecordset derived objects) and
2.) the thread function (or even just a regular function) in a separate DLL containing the algorithms.
0
 
LVL 1

Accepted Solution

by:
TheGrinch earned 100 total points
ID: 1176525
The CRecordset classes should go in your Document class, and should all share a single database connection. That is, create a CDatabase object and use it when constructing the CRecordsets.

The thread should create a different database connection, and instantiate a separate set of CRecordset objects using this connection.

There is no advantage to having a single set of CRecordsets. They will be defined only once, but instantiated twice. Sharing a single set between the main App and the thread introduces many complexities but offers no gain.

Your design is reasonable.
0
 
LVL 1

Expert Comment

by:TheGrinch
ID: 1176526
No comment -- I just forgot to check the notify box.
0

Featured Post

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

831 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