Solved

How to design a VC++/MFC database application

Posted on 1998-10-29
7
214 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Which IDE to use to begin C++ training? 5 59
Compile GLUT with Visual Studio 2015 1 108
C++ question 3 61
max float value 3 23
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

914 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

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now