1. Olan Knight
  2. PowerBuilder
  3. Friday, 11 June 2021 20:44 PM UTC

PB2019R3, build 2703


I read through the previous post on this topic:
   https://community.appeon.com/index.php/qna/q-a/dsn-less-connection-postgresql-solved

This was the template solution listed:
   Sqlca.DBMS =ODBC
   Sqlca.DBParm="Driver={PostgreSQL ODBC Driver(UNICODE)};DATABASE=db;SERVER=192.168.x.x;PORT=5432;UID=postgres;PWD=pass";

I tried to implement it, but I'm still getting prompted to connect to a DSN when the CONNECT command is called.

What am I doing wrong?
Yes, I removed the braces!  :)

All of the Registry entries exist:

Even when I simplify the connection object SQLCA to the point of minimal, the same thing occurs:

 

 

 

Accepted Answer
Sivaprakash BKR Accepted Answer Pending Moderation
  1. Monday, 14 June 2021 06:50 AM UTC
  2. PowerBuilder
  3. # Permalink
0
Votes

Olan,

Exactly that is what we do (DSN Less connection) to connect to Postgresql 11 from PB 2019 R3 application.  It's working.   We read details from a ini file.   Here is a snippet

*******************************************************
SQLCA.DBMS = ProfileString (ls_ini_name, "Profile " + Trim(ls_profile), "DBMS", '????')
SQLCA.DBParm = ProfileString(ls_ini_name, "Profile " + Trim(ls_profile), "DBParm", "")
SQLCA.Lock = ProfileString(ls_ini_name, "Profile " + Trim(ls_profile), "Lock", '????')
SQLCA.Servername = ProfileString(ls_ini_name, "Profile " + Trim(ls_profile), "ServerName", '????')
SQLCA.Autocommit = True

ll_sqlca = SQLCA.of_connect();
********************************************************

contents of the ini file   [ ini file will contain profile of more than one database, and user can choose one in the login screen ]

***************************************************
[Profile Yasotha Motors]
DBMS=ODBC
ServerName=192.168.1.76
DBParm="ConnectString='Driver=PostgreSQL Unicode;Database=yasothamotors;Server=192.168.1.76;Port=5432;UID=user;PWD=pass;',DisableBind=1"
Lock="RC"
***********************************************

We construct the DBParm string in a separate input screen and write that value in the ini file.

ODBC driver plays and important role here.  Depending on the driver file, it installs in different name.  Try to use the same driver file in every place.   We use psqlodbc_x86.exe, which installs the driver in the name 'PostgreSQL Unicode'.  [ and also PostgreSQL ANSI].  

It works fine from exe so far [ installed in 2 client places, so far apart from my office ]

HTH

Happiness Always
BKR Sivaprakash

 

Comment
  1. Olan Knight
  2. Monday, 14 June 2021 14:18 PM UTC
I hardcoded my connection data in the format you specified - and it worked!

Thank you!
  1. Helpful
  1. Sivaprakash BKR
  2. Tuesday, 15 June 2021 05:33 AM UTC
You are welcome, Olan.
  1. Helpful
There are no comments made yet.
Arnd Schmidt Accepted Answer Pending Moderation
  1. Sunday, 13 June 2021 13:16 PM UTC
  2. PowerBuilder
  3. # 1

Hi Olan,

you can use that string in the ODBC Connection Properties in the Database Profile Setup.

Do not set a Datasource (!), but use the Driver-Specific Parameters.

If you switch to the preview tabpage you see that PowerBuilder uses a ConnectString='<yourString>' Syntax.

So your DBParm String should look like:

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

Evenually also DRIVER=PostgreSQL Unicode instead of Driver=PostgreSQL ODBC Driver(UNICODE) is the key to success.

Just try/test in the Database Profile Setup to find "your" DBParm including the Connection String and other possible switches.

hth

Arnd

 

Comment
  1. Olan Knight
  2. Sunday, 13 June 2021 20:58 PM UTC
Thank you, Arnd, I'll try that.

How does that work when I send the EXE to our clients?
  1. Helpful
  1. Arnd Schmidt
  2. Monday, 14 June 2021 08:11 AM UTC
Hi Olan,

BKR Sivaprakash gave a good idea for a solution.

You can implement a dialog where the user can set the database related settings and save it to a local INI-File.



hth



Arnd
  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.