Solved

COM in Win32

Posted on 2000-04-25
3
297 Views
Last Modified: 2013-12-03
Im asked to write a program which will utilize MS databases.  I can write in any language I want.  I was going to use VB only because it allows access to COM objects such as ADO & DAO a lot easier than C.  But Im more familiar with using Win32 C calls and I like its efficency more, so Id like to try my hand at it in Win32.

Im not unfamiliar with COM (played with DirectX) but I haven't used it extensively.  Im wondering how I would access the DAO and/or ADO objects from within a Win32 app.  How would I find out the CLSID for it?  And how would I use CoCreateInstance() to load the components?

Thanks,
-Dan    
0
Comment
Question by:dmaroff
  • 2
3 Comments
 
LVL 23

Accepted Solution

by:
chensu earned 75 total points
ID: 2748441
First of all, you should use ADO instead of DAO for new applications. DAO is obselete.

Using ADO in C++ with #import can be as easy as in VB. Look into the ADO documentation. There are samples and tutorials.

Microsoft ActiveX Data Objects (ADO)
http://msdn.microsoft.com/isapi/msdnlib.idc?theURL=/library/psdk/dasdk/ados4piv.htm
0
 

Author Comment

by:dmaroff
ID: 2748688
It seems do-able but for some reason, I cant seem to open a recordset using a query:

-------------------------------------
dbPtr->Open("SELECT CITY FROM INFO_FCI WHERE ZIP = 10987", _variant_t((IDispatch *)pConnection,true), adOpenKeyset, adLockOptimistic, NULL);
------------------------------------
City is a attribute and so is zip.  But yet I get a "datatype mismatch error".
It seems that ADO in C is little different in VB.  Can you shoe me a few different SQL statement examples using this function.

Also, is there a seperate query function thats part of the _recordset object where I can requery the database, or do I just have to create another recordset?

Thanks,
-Dan
0
 
LVL 23

Expert Comment

by:chensu
ID: 2749189
>But yet I get a "datatype mismatch error".

I have no idea.

>Also, is there a seperate query function thats part of the _recordset object where I can requery the database, or do I just have to create another recordset?

You may use the Requery method or use the Close and Open methods.
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

This article shows how to make a Windows 7 gadget that accepts files dropped from the Windows Explorer.  It also illustrates how to give your gadget a non-rectangular shape and how to add some nifty visual effects to text displayed in a your gadget.…
If you have ever found yourself doing a repetitive action with the mouse and keyboard, and if you have even a little programming experience, there is a good chance that you can use a text editor to whip together a sort of macro to automate the proce…
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

776 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