title: C++ ADO Connection
body: <p>I am trying to read an excel file. I am trying to make a simple ADO connection using C++. But while opening the connection it is getting failed.</p>
  
  <p>this is the code am using</p>
  
  <pre><code>#import "C:\Program Files (x86)\Common Files\System\ado\msado15.dll" rename_namespace("ADOCG") rename("EOF", "EndOfFile")
  
  int _tmain(int argc, _TCHAR* argv[])
  {
      ADOCG::_ConnectionPtr conn = NULL;
      ADOCG::_RecordsetPtr rset = NULL;
  
      conn.CreateInstance(__uuidof(ADOCG::Connection));
      rset.CreateInstance(__uuidof(ADOCG::Recordset));
  
      try
      {
          //bstr_t bstrCnxt("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\\sample.mdb;Extended Properties='MSAccess 12.0;HDR=Yes'"); 
          conn-&gt;Open("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\\weightreport.xls;Extended Properties='Excel 12.0;HDR=Yes'","","", ADOCG::adConnectUnspecified);
  
      }
      catch(const char * str)
      {
  
      }
  }
  </code></pre>