Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I connect to SQL Server 2016 in PowerBuilder Classic 12.5.2?

I am supporting a legacy application written in PB Classic that has a hardcoded connection string using SQL Server Native Client (SQLNCLI10). However, the Native Client is not supported beyond SQL Server 2012. It works in 2014, but it isn't supported. We have several databases that are now running SQL Server 2016 that cannot use SQLNCLI10 or SQLNCLI11.From what I understand, we can roll out an update to the native client as long as we don't intend to use any of the features in SQL Server 2016 but that seems like more of a stop-gap measure than a real solution. However, when I attempt to change the DBMS from native client to use the new ODBC drivers using a FileDNS entry in DBParm, the client always prompts for the location of the DSN file and other connection properties.

What is the best way to connect to SQL Server 2016 (preferably using the ODBC 13 for SQL Server 2016 drivers) in PowerBuilder Classic? This is what we're currently using (after scrubbing details):

sqlca.DBMS = 'SNC SQL Native Client(OLE DB)'
this.DBParm = "Database='" + as_database + "',Provider='SQLNCLI10',Identity='SCOPE_IDENTITY()',TrimSpaces=1,StaticBind=0,PBCatalogOwner='dbo', appname = 'My Application' , host =' " + lower(ls_machine_name) + "' "
like image 737
Elsimer Avatar asked Jan 21 '26 05:01

Elsimer


1 Answers

After some trial and error, I was able to connect using the following:

SQLCA.DBMS = "ODBC"
SQLCA.DBParm = "ConnectString='Driver={ODBC Driver 13 for SQL Server};QuotedId=No;TrustServerCertificate=Yes;Encrypt=Yes;Trusted_Connection=Yes;SERVER=" + SQLCA.ServerName + ";'"

I went a bit further and tried it with a SQL Authentication by adding UID= and PWD= into the DBParm replacing the Trusted_Connection portion of the string. I also added the Database parameter (the initial string was just making a connection to the default master database). Like this:

SQLCA.DBParm = "ConnectString='Driver={ODBC Driver 13 for SQL Server};QuotedId=No;TrustServerCertificate=Yes;Encrypt=Yes;UID="+SQLCA.Logid+";PWD="+SQLCA.LogPass+";SERVER=" + SQLCA.ServerName + ";Database="+SQLCA.Database+";'"
like image 181
Elsimer Avatar answered Jan 23 '26 19:01

Elsimer



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!