Solved

Accessing queries internal to a database w/ ODBC and VC++ 1.52

Posted on 1998-07-17
9
158 Views
Last Modified: 2013-11-20
We're doing Win3.1 deveopment at work, and I need to access queries that are
stored in an Access 2.0 .mdb file, using ODBC 2.1.  Any solutions?
0
Comment
Question by:bry
  • 4
  • 3
  • 2
9 Comments
 
LVL 7

Expert Comment

by:psdavis
Comment Utility
Use the CRecordset class to open up the query very much like a regular recordset.

Phillip

0
 

Expert Comment

by:bobplace
Comment Utility
Use CDaoQueryDef.  It will open the query for you.  Then you can open a CDaoRecordset using the CDaoquerydef ratehr than a CDaoDatabase.
0
 
LVL 7

Expert Comment

by:psdavis
Comment Utility
We both wish.  CDaoQueryDef is 32-bit.  We're still 16-bit ODBC aren't we?

Phillip

0
 

Author Comment

by:bry
Comment Utility
Please note: ODBC is *NOT* DAO.  I cannot use CDaoQueryDef
because DAO wasn't around when VC++ 1.52 was released, hence
it's version of MFC does not support DAO.  I'm trying to
port this app from MFC 4.2 to MFC 2.5 (or whatever it is that
shipped w/ VC++).

0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 

Expert Comment

by:bobplace
Comment Utility
Oh, I see you are moving to a lower platform.  Sorry I gave up on the 16 bit world several years ago.  Never mind....
0
 
LVL 7

Expert Comment

by:psdavis
Comment Utility
If all you're trying to do is port a Win32 program down to Win16, how about Win32s?  I believe that you still gain your DAO implementation, and it should help with absolutely everything else you're trying to convert.

Phillip

0
 

Author Comment

by:bry
Comment Utility
We've already tried Win32s, and there are some problems w/ it
(particularly w/ property sheets).  Also, it slows Win3.1
down a bit, and we're having problems with speed already (we
have a 200,000-entry database to manipulate).

I may have found a solution, though.  I'll have to wait 'til
I get to work tomorrow to see what happens.

Thanks

Bry
0
 

Author Comment

by:bry
Comment Utility
Okay, the problem is fixed -- here's what needs to be done, for
those out there who are doing Win3.1 development:

1. Create a CRecordset w/ ClassWizard that accesses one of the
tables that your query uses

2. Add/delete member variables from your recordset class to
reflect the columns of data returned by the query - you may
have to add some manually outside the ClassWizard-defined
braces

3. Initialize your vars, and also edit the Record Field Exchange
part of your class to reflect the vars you added - note if you
have parameters you want to send to the query, you will also
have to add those member vars and set them up in the Field
Exchange as well - see the docs

4. You're now ready to open the query.  First, initialize all
your parameters (if you have them) w/ whatever data you want
to send to the query.  Then, construct a CString as follows:

CString mySQL = _T("{CALL myquery ( <params> )}");

where 'myquery' is the name of the query stored in the DB.
Then create an instance of your recordset, and open it with:

myCRecordSet.Open(CRecordset::snapshot, mySQL, CRecordSet::readOnly);

This will open the query and begin the Field Exchange as normal.


PS -
I don't know how to get the points back, so I guess the first
person who responds can have them.
0
 
LVL 7

Accepted Solution

by:
psdavis earned 100 total points
Comment Utility
I'll go ahead and claim them if you don't mind!

Phillip

0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
how to monitor remote shell execution on linux 9 92
no14 challenge 14 56
wait notify demo infinite loop 3 79
Sed question 2 45
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
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.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

763 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

11 Experts available now in Live!

Get 1:1 Help Now