Skip to Content
0

SetTransobject Fails

Jan 19, 2017 at 03:27 PM

286

avatar image
Former Member

Hello,

I am trying to setup a db connection in runtime to SQL Server 2014 database that reside on a different Server. The connection is successful but when I try to set the transaction object for a datastore, it Fails.

I am using PB Classic 12.6.3506. Also, I am able to set up this DB connection in the PB IDE connections and can create dataobject against it and/or run queries. Also, I can successfully issue Direct SQL against this transaction object in runtime.

Any ideas?

Thanks in advance!

Shai

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

9 Answers

avatar image
Former Member Jan 19, 2017 at 04:13 PM
0

Are you sure that the DataWindow object was included in the executable? You might have to use a PBR file to force it's inclusion.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Jan 19, 2017 at 04:15 PM
0

Show some code and define exactly what "fails" means. If the application crashes, then that implies your datastore reference is not valid.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Jan 19, 2017 at 04:36 PM
0

I forgot to mention....I am still testing some changes. It fails in debug.

Not much to show....return code is -1.

li_rc = lds_test.SetTransObject(SqlProd)

Shai

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

If SetTransObject fails, then Roland's suggestion is likely. The other thing to check is that you have created and connected SqlProd BEFORE you assign it to your datastore. Did you also declare SqlProd as a global variable?

And the values you set in the transaction object look highly suspicious. The value "Release='15' is not familiar to me but I think it is Sybase-specific. I wasn't aware that you could use SNC to connect to anything other than MS SQL Server. The values you posted as that in your code don't match the values you posted as the ones in the preview tab of the IDE. Using SNC you have to specify the database in dbparm; the database attribute is not used. And you need to set the servername attribute - just like the preview tab.

0
avatar image
Former Member Jan 19, 2017 at 04:55 PM
0

Here is the code where I setup the connection Transaction variables:

SqlProd.DBMS         =  "SNC SQL Native Client(OLE DB)" 
SqlProd.database = "dba"
SqlProd.logid = "SomeUser"
SqlProd.logpass = "Password"
SqlProd.autocommit = True
SqlProd.dbparm = "Release='15', DisableBind = 1, AppName = '" + gnv_myapp.of_getappname( ) + "'" + ", Host = '" + gnv_myapp.of_getcomputername() 
SqlProd.servername = 'ServerName'

// Connect to the database using the transaction object we just initialized.

CONNECT USING SqlProd; (this returns 1)

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Jan 20, 2017 at 04:35 PM
0

Did you assign the DataObject to the DataStore variable first?

DataStore lds_test

lds_test = Create DataStore

lds_test.DataObject = "d_test"

li_rc = lds_test.SetTransObject(SqlProd)

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

Yes I did.

0
Ricardo Jasso Jan 23, 2017 at 04:08 AM
0

Can you show us the database connection syntax from the Preview tab for the PB IDE connection?

When using this driver I always set the database parameter inside the DBParm property:

SQLCA.DBParm = "Database='mydb',Provider='SQLNCLI10'"

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Jan 23, 2017 at 02:35 PM
0
SQLCA.DBMS = "SNC SQL Native Client(OLE DB)"
SQLCA.LogPass = <***********>
SQLCA.ServerName = "My Server"
SQLCA.LogId = "GenericUser"
SQLCA.AutoCommit = False
SQLCA.DBParm = "Database='dba',Provider='SQLNCLI10'"

This connect successfully.
Share
10 |10000 characters needed characters left characters exceeded
Ricardo Jasso Jan 24, 2017 at 08:13 PM
0

So try using the same format when populating the properties of your transaction object SqlProd to see if there's any difference.

SqlProd.DBMS ="SNC SQL Native Client(OLE DB)"

SqlProd.servername ='ServerName'

SqlProd.logid ="SomeUser"

SqlProd.logpass ="Password"

SqlProd.autocommit = True

SqlProd.dbparm ="Database='dba',Provider='SQLNCLI10',Release='15', DisableBind = 1, AppName = '" + gnv_myapp.of_getappname( ) + "'" + ", Host = '" + gnv_myapp.of_getcomputername() + "'"

Also, I think you missed a last apostrophe after the computer name. I included it here.

Share
10 |10000 characters needed characters left characters exceeded
avatar image
Former Member Feb 02, 2017 at 08:22 PM
0

Double check the dbparm string. You may need to use semi colons (;) in place of some of the commas (,) you show.

Share
10 |10000 characters needed characters left characters exceeded