Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

ADO CreateInstance() Problem?

Posted on 2001-08-05
2
Medium Priority
?
438 Views
Last Modified: 2013-11-20
I have a simple console app that I'm trying to use ado to connect to.
When I run my code:
spADOConn.CreateInstance( __uuidof(Connection));
spADOConn seems to always contain the value of
0x000...

Am I doing something wrong here?
My stdafx.h only contains the following:
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

Here is my code:

#include "stdafx.h"
#include <stdio.h>

#pragma warning(disable: 4146)
#import "C:/Program Files/Common Files/System/ADO/MSADO15.DLL" \
no_namespace rename("EOF","adoEOF")
#pragma warning(default: 4146)


int main(int argc, char* argv[])
{
     _ConnectionPtr spADOConn = NULL;

     try
     {
         

          spADOConn.CreateInstance( __uuidof(Connection));

          spADOConn->Mode = adModeReadWrite;
          if (SUCCEEDED(spADOConn->Open("Data Source=ADOClientDS",
               "","",adConnectUnspecified)))
          {
               spADOConn->Close();

               printf( "True" );
          }
          else
          {
               printf( "Err" );
          }
     }
     catch( ... )
     {

     }
     return 0;
}
0
Comment
Question by:borg48
[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 Comments
 
LVL 23

Accepted Solution

by:
naveenkohli earned 200 total points
ID: 6357114
Call CoInitialize right at the start of the main function. This will initilaize the COM libraries that you need to create the COM objects,
0
 

Author Comment

by:borg48
ID: 6357907
Thanks allot
0

Featured Post

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
This course is ideal for IT System Administrators working with VMware vSphere and its associated products in their company infrastructure. This course teaches you how to install and maintain this virtualization technology to store data, prevent vuln…
Suggested Courses

705 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