Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 190
  • Last Modified:

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

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
bry
Asked:
bry
  • 4
  • 3
  • 2
1 Solution
 
psdavisCommented:
Use the CRecordset class to open up the query very much like a regular recordset.

Phillip

0
 
bobplaceCommented:
Use CDaoQueryDef.  It will open the query for you.  Then you can open a CDaoRecordset using the CDaoquerydef ratehr than a CDaoDatabase.
0
 
psdavisCommented:
We both wish.  CDaoQueryDef is 32-bit.  We're still 16-bit ODBC aren't we?

Phillip

0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
bryAuthor Commented:
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
 
bobplaceCommented:
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
 
psdavisCommented:
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
 
bryAuthor Commented:
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
 
bryAuthor Commented:
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
 
psdavisCommented:
I'll go ahead and claim them if you don't mind!

Phillip

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now