Solved

COM in Win32

Posted on 2000-04-25
3
299 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
[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
  • 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

After several hours of googling I could not gather any information on this topic. There are several ways of controlling the USB port connected to any storage device. The best example of that is by changing the registry value of "HKEY_LOCAL_MACHINE\S…
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
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…

762 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