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

    Unanswered: Problem in Connecting to PostgreSQL using C++

    Dear Friends,

    I am in big trouble. Please help me.


    Our server is running on linux and having PostgreSQL installed. I have written a C++ program to access programmatically using ADO concepts to that database (PostgreSQL). But I am encountering problems

    The connection string I used like this :

    "Provider=PostgreSQL OLE DB Provider;Location=bmc;Data Source=192.168.88.204,5432;UserID=postgres;Passwor d=postgres";

    But the error I got is

    "Provider cannot be found. It may not be properly installed."

    Alternatively I have used like this also, PGOLEDB as the Provider name. But also useless. Same error message I got.

    Could any one of you help me to find out solution how to connect programmatically to the postgreSQL using C++ ????

    Thank you in advance.

  2. #2
    Join Date
    Mar 2007
    Location
    636f6d7075746572
    Posts
    770
    Do you have the OLE DB extensions installed for C++ with Postgresql ?
    Do you have the OLE DB drivers installed?

  3. #3
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    check out the third post in the VB FAQ. It's regarding building a utility to build your OleDB connection strings. (plus, the compiled utility is available for download as an msi file)
    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


  4. #4
    Join Date
    May 2007
    Posts
    2
    Thank you friends for you kind reply.


    I installed the PGOLEDB.dll in my (Win-XP) PC and then tried connecting to the linux server (running Postgresql) again thru my C++ code, but now I got a different error like below:

    "could not connect to server: Connection refused (0x0000274D/10061)
    Is the server running on host "192.168.88.204,5432" and accepting
    TCP/IP connections on port 5432?"


    Please help me to resolve this issue .......

    The connection string i used was :
    "Provider=PostgreSQL OLE DB provider;Data Source=192.168.88.204,5432;location=bmc;UserID=pos tgres;password=postgres;timeout=3000";

    I tried using the connection string with a colon in between IP and Port instead of comma like below:

    "Provider=PostgreSQL OLE DB provider;Data Source=192.168.88.204:5432;location=bmc;UserID=pos tgres;password=postgres;timeout=3000";

    also results in the same error

    But when I removed the port number from the Data source, then I got a different error

    "FATAL: invalid command-line arguments for server process
    HINT: Try "postgres --help" for more information."


    Please help me to resolve this issue

  5. #5
    Join Date
    Jun 2004
    Location
    Arizona, USA
    Posts
    1,848
    IF you install that little utility I pointed out, you can use it to choose the provider, supply host info, credentials, and default database, and then test the connection. After which, the connection string used (and tested) is placed into the clipboard.
    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


  6. #6
    Join Date
    Jun 2009
    Posts
    2

    Try to use port argument

    Perhaps you missing something in your connection string, try to use this one:

    Provider=PostgreSQL OLE DB Provider;Location=posdbv2005;Data Source=10.10.10.27;Port=5433;UserID=postgres;Passw ord=d link5 17

    instead of yours:

    Provider=PostgreSQL OLE DB Provider;Location=posdbv2005;Data Source=10.10.10.27,5433;UserID=postgres;Password=d link5 17

    Hope it works.

Posting Permissions

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