Powerbuilder 2nd transaction object

I am writing a powerbuilder app that needs a second transaction object.
The connect string is supplied via an ini file.
The Transaction object works fine until I add code to update a datawindow that belongs to the SQLCA object that has been modified in a prior script. I need to update this datawindow before I can do the work associated with the following transaction object.
If the datawindow update code is commented out, the creation of the trans obj works fine.

The code dies in "of_init" by returning the -1 from the following ----

if IsNull (as_inifile) or IsNull (as_inisection) or &
      Len (Trim (as_inifile))=0 or Len (Trim (as_inisection))=0 or &
      (not FileExists (as_inifile)) then return -1

The offending code looks like this ----
 
ll_save_dw_return = dw_fix_names.update()  <-- This belongs SQLCA and was modified in a prior script
If ll_save_dw_return <> 1 Then
	MessageBox("Error",'Changes to names failed because ' + sqlca.SQLErrText )
	Return
Else
	COMMIT;
End if
 
 
NameDB = Create n_tr
ls_inifile = gnv_app.Of_GetAppIniFile( )
If NameDB.Of_Init(ls_inifile, "NameBase") = -1 THEN
	li_messagebox_response = MessageBox('Transfer File', 'The connection to the Name DataBase Failed -- Notify Systems!')
	Return
END IF

Open in new window

noreenburkeAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

diasroshanCommented:
Hi,

make sure ur connecting each DW using the right transaction object.
Like, dw_fix_names.SetTransObject(SQLCA)

Can u post ur code where u connect to another transaction object.

Please refer the below posts, thats how i use it.
http://www.experts-exchange.com/Programming/Editors_IDEs/PowerBuilder/Q_22943109.html

Also,
http://www.experts-exchange.com/Programming/Editors_IDEs/PowerBuilder/Q_21037794.html

Cheers,
Rosh

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
noreenburkeAuthor Commented:
Hi Rosh:
   Thanks for responding.
   The second transaction object will not have a datawindow associated with it, all the database interaction will take place in the local script.
   If I remove the DW.update statement  for the SQLCA datawindow(everything else is the same), I am able to connect to the second database without a problem. If I leave the update statement in, The code crashes while attempting to acquire the connection string for the second DB from the .ini file. It crashes early in the "of_init" function.

The illustration of the difference:

The code thatdoes not work:

ll_save_dw_return = dw_fix_names.update()  <-- This belongs SQLCA and was modified in a prior script
If ll_save_dw_return <> 1 Then
      MessageBox("Error",'Changes to names failed because ' + sqlca.SQLErrText )
      Return
Else
      COMMIT;
End if
 
NameDB = Create n_tr
ls_inifile = gnv_app.Of_GetAppIniFile( )
If NameDB.Of_Init(ls_inifile, "NameBase") = -1 THEN
      li_messagebox_response = MessageBox('Transfer File', 'The connection to the Name DataBase Failed -- Notify Systems!')
      Return
END IF

The code that does:

//ll_save_dw_return = dw_fix_names.update()  <-- This belongs SQLCA and was modified in a prior script
//If ll_save_dw_return <> 1 Then
//      MessageBox("Error",'Changes to names failed because ' + sqlca.SQLErrText )
//      Return
//Else
//      COMMIT;
//End if
 
NameDB = Create n_tr
ls_inifile = gnv_app.Of_GetAppIniFile( )
If NameDB.Of_Init(ls_inifile, "NameBase") = -1 THEN
      li_messagebox_response = MessageBox('Transfer File', 'The connection to the Name DataBase Failed -- Notify Systems!')
      Return
END IF

Thanks Again

diasroshanCommented:
Hi,

can u paste the code for gnv_app.Of_GetAppIniFile( ) and the ini file
And, the line where it crashes.

before that just try replacing 'COMMIT' with 'COMMIT USING SQLCA;' and see if it works for u.

Cheers,
Rosh
noreenburkeAuthor Commented:
Hi Rosh:
   The solution to my problem turned out to be -- moving the transaction object creation to the open of the window instead of local to the database manipulation. I still don't understand why it didn't like the local creation but I don't have time to dwell on it right now.
Thanks for your help
noreenburkeAuthor Commented:
Rosh's answer did not directly solve the specific issue but led me to an acceptable solution.
Thanks Again
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.