- Olan Knight
- PowerBuilder
- Tuesday, 15 June 2021 08:35 PM UTC
Resolution:
Mark Goldsmith noticed that I was storing double quotes with the connection string information.
Removing the stored double-quotes solved the problem!
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
PB2019R3
Dear Appeon:
Internally in PB2019R3, what is the difference between a hard-coded string in the application, and a string variable that is created in script?
Example:
1) I have a hard-coded string in gnv_appmgr.pfc_logon_env. When the code looks like this, a connection is made to the PostgreSQL database without prompting me for a DSN. This is the behavior I expect. Note the hardcoded value is set to sqlca.dbparms at the bottom of the snippet.
SQLCA.AutoCommit = False
SQLCA.Database = ""
SQLCA.DBMS = ls_dbms
SQLCA.DBParm = ""
SQLCA.LogId = as_userid
SQLCA.LogPass = as_password
SQLCA.ServerName = ls_ip_addr
SQLCA.DBParm = "ConnectString='Driver=PostgreSQL Unicode;Database=nttest;Server=10.50.68.244;Port=5444;UID=cabdevusr;PWD=cabdevusr;',DisableBind=1,UseServerSidePrepare=1,PBCatalogOwner='chadba',StripParmNames='Yes'"
2) When the DBPARM string is constructed (or read into the app) and CONNECT is called, I am prompted for a DSN.
// Get the connect string to be updated
ls_DBParm = "ConnectString='Driver=<driver>;Database=<db>;Server=<ip>;Port=<port>;UID=<userid>;PWD=<password>;'
Each token encased in angle brackets is then replaced, item by item. The resulting string is identical to the hard-coded string, but it prompts for a DSN when the CONNECT is called.
3) I put the hard-coded connection string into the Registry, read it into the app, and used that string in SQLCA.DBPARMS, and I was prompted for a DSN.
ls_key = "HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\CSGI\Logon\DBMS\PostgreSQL\nttest_PG"
RegistryGet (ls_key, "sqlca_dbparms", RegString!, ls_DBParm)
SQLCA.AutoCommit = False
SQLCA.Database = ""
SQLCA.DBMS = ls_dbms
SQLCA.DBParm = ls_DBParm
SQLCA.LogId = as_userid
SQLCA.LogPass = as_password
SQLCA.ServerName = ls_ip_addr
//---------- DEBUG -----------------------
ls_DBParm = "ConnectString='Driver=PostgreSQL Unicode;Database=nttest;Server=10.50.68.244;Port=5444;UID=cabdevusr;PWD=cabdevusr;',DisableBind=1,UseServerSidePrepare=1,PBCatalogOwner='chadba',StripParmNames='Yes'"
Here's the actual code. This is the ONLY way I have been able to connect without being prompted for a DSN.
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.