Results 1 to 3 of 3
  1. #1
    Join Date
    May 2007
    Posts
    2

    Question Unanswered: Problem connecting to PostgreSQL using ADO

    Hi, everyone
    I am writting an C++ application using VC++ 2005 Express Edition to access data in PostgreSQL. I have used the "xx.udl" file to test and generate the connection string. The connectin was successfully tested. But, I am promted with the error in msado15.tlh with a lot of syntax error.
    Can any one help me?

  2. #2
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    probably NOT without you showing us the code in question, the error generated, the location of the error, and the connection string used...

    (there are a lot of good c++ programmers out there, however, I'm not one of them )
    Lou
    使大吃一惊
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert


  3. #3
    Join Date
    May 2007
    Posts
    2

    Question The connection string

    Sorry if I didn't make my question clear. Below is part of my coding:

    #include "stdafx.h"
    #include <iostream>
    #include <string>

    #import "C:\Program files\Common Files\System\Ado\msado15.dll"

    rename("EOF", "ADOEOF")
    std::string outputashex(unsigned long l)
    {
    char buffer[1024];
    ::itoa(l, buffer, 16);
    return buffer;
    } ;
    void _tmain()
    {
    HRESULT hr;
    CoInitialize(NULL);
    try
    {
    ADODB::_ConnectionPtr connection;
    hr = connection.CreateInstance(__uuidof(ADODB::Connecti on));
    if (FAILED(hr))
    {
    throw _com_error(hr);
    }
    ADODB::_RecordsetPtr recordset;
    hr = recordset.CreateInstance(__uuidof(ADODB::Recordset ));
    if (FAILED(hr))
    {
    throw _com_error(hr);
    }
    connection->CursorLocation = ADODB::adUseClient;
    connection->Open(L"Provider=MSDASQL.1;Persist Security Info=False;Data Source=PostgreSQL30;"
    L"Initial Catalog=mydb2;User Id=postgres;Password=xxxxxx;", L"",
    L"", ADODB::adConnectUnspecified);
    .
    .
    .
    The compile error as below:

    c:\program files\microsoft visual studio 8\vc\include\comdef.h(24) : fatal error C1083: Cannot open include file: 'ole2.h': No such file or directory
    This error occurred in injected text:

    //+++ Start Injected Code
    #injected_line 9 "c:\\documents and settings\\administrator\\my documents\\visual studio 2005\\projects\\myconn\\myconn\\myconn.cpp"
    #include <comdef.h>
    //--- End Injected Code

    I found that the ole2.h file is not inside the include directory of VC. After I manually adds the ole2.h file and pshpack8.h file, it comes up with another compiling error :

    c:\program files\microsoft visual studio 8\vc\include\pshpack8.h(7) : fatal error C1189: #error : "8 as alignment is not supported"
    This error occurred in injected text:
    #include <comdef.h>
    //--- End Injected Code

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •