1. Sivaprakash BKR
  2. PowerBuilder
  3. Monday, 11 December 2017 08:34 AM UTC

Hello,

PB 2017, Postgresql 10.1

I want to connect to postgresql without creating any DSN, which didn't succeed with the following code.

Sqlca.DBMS =ODBC
Sqlca.DBParm="Driver={PostgreSQL ODBC Driver(UNICODE)};DATABASE=db;SERVER=192.168.x.x;PORT=5432;UID=postgres;PWD=pass";

 
With DSN it works fine. Would like to connect without DSN.  Couldn't understand where the problem lies.
 

Happiness Always
BKR Sivaprakash

René Ullrich Accepted Answer Pending Moderation
  1. Monday, 11 December 2017 11:15 AM UTC
  2. PowerBuilder
  3. # 1

I use ConnectString='DRIVER=PostgreSQL Unicode;...' and it works for me.

You have to register the driver dlls as Marco wrote.

Have you tried to remove the { } in your DRIVER statement?

Comment
  1. Sivaprakash BKR
  2. Monday, 11 December 2017 14:54 PM UTC
Thanks Rene Ullrich.  It's working, after removing the { } braces.   I tried all other combinations, except the curly braces.  Thanks.



Happiness Always

BKR Sivaprakash



 

  1. Helpful
There are no comments made yet.
Marco Meoni Accepted Answer Pending Moderation
  1. Monday, 11 December 2017 09:09 AM UTC
  2. PowerBuilder
  3. # 2

Hello Sivaprakash,
A DSN in ODBC Datasource Administrator is just a bunch of Windows Registry settings.
You need to set these settings when the PB application starts (and maybe remove what it closes).
Here below what you need (check that key name and value in the first two RegistrySet correspond to the version on your DEV machine):

RegistrySet("HKEY_LOCAL_MACHINE\Software\ODBC\ODBCINST.INI\PostgreSQL ODBC Driver(UNICODE)", "Driver", RegString!, "PSQLODBC.dll")
RegistrySet("HKEY_LOCAL_MACHINE\Software\ODBC\ODBCINST.INI\PostgreSQL ODBC Driver(UNICODE)", "Setup", RegString!, "PSQLODBC.dll")
RegistrySet("HKEY_LOCAL_MACHINE\Software\ODBC\ODBCINST.INI\ODBC Drivers", "PostgreSQL ODBC Driver(UNICODE)", RegString!, "Installed")

Then you can keep the sqlca.odbc and sqlca.dbparm settings before the CONNECT.
Cheers,
Marco

Comment
  1. Sivaprakash BKR
  2. Monday, 11 December 2017 11:18 AM UTC
Thanks Marco Meoni.



I've already installed the driver and those registry settings are available.  Only change being the dll file name is set to  psqlodbc35w.dll instead of psqlodbc.dll.



Creating a DSN and connecting it works fine.   Trying to connect without creating a DSN.  Want to avoid creating a DSN every time in every computer (at client place).



Happiness Always

BKR Sivaprakash



 

  1. Helpful
  1. Roland Smith
  2. Monday, 11 December 2017 13:43 PM UTC
The program could create the DSN settings in the registry if missing prior to connecting.

  1. Helpful
There are no comments made yet.
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.
We use cookies which are necessary for the proper functioning of our websites. We also use cookies to analyze our traffic, improve your experience and provide social media features. If you continue to use this site, you consent to our use of cookies.