Solved

COM in Win32

Posted on 2000-04-25
3
295 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
Comment Utility
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
Comment Utility
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
Comment Utility
>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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

For a while now I'v been searching for a circular progress control, much like the one you get when first starting your Silverlight application. I found a couple that were written in WPF and there were a few written in Silverlight, but all appeared o…
For most people, the WrapPanel seems like a magic when they switch from WinForms to WPF. Most of us will think that the code that is used to write a control like that would be difficult. However, most of the work is done by the WPF engine, and the W…
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…

743 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

17 Experts available now in Live!

Get 1:1 Help Now