Solved

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

Posted on 1998-07-17
9
181 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 7

Expert Comment

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

Phillip

0
 

Expert Comment

by:bobplace
ID: 1319411
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
ID: 1319412
We both wish.  CDaoQueryDef is 32-bit.  We're still 16-bit ODBC aren't we?

Phillip

0
Will your db performance match your db growth?

In Percona’s white paper “Performance at Scale: Keeping Your Database on Its Toes,” we take a high-level approach to what you need to think about when planning for database scalability.

 

Author Comment

by:bry
ID: 1319413
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
 

Expert Comment

by:bobplace
ID: 1319414
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
ID: 1319415
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
ID: 1319416
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
ID: 1319417
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
ID: 1319418
I'll go ahead and claim them if you don't mind!

Phillip

0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

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: 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.
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…

635 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