Solved

COM in Win32

Posted on 2000-04-25
3
298 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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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

Suggested Solutions

Title # Comments Views Activity
Duplicates in Aggregate Query 3 44
Alternative to visual sourcesafe 2 131
Strange - Deleted Resource Info appears in Azure Portal 6 91
PL SQL Developer 7 53
zlib is a free compression library (a DLL) on which the popular gzip utility is built.  In this article, we'll see how to use the zlib functions to compress and decompress data in memory; that is, without needing to use a temporary file.  We'll be c…
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…

856 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