• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1962
  • Last Modified:

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

0
noreenburke
Asked:
noreenburke
  • 3
  • 2
1 Solution
 
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
0
 
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

0
 
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
0
 
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
0
 
noreenburkeAuthor Commented:
Rosh's answer did not directly solve the specific issue but led me to an acceptable solution.
Thanks Again
0

Featured Post

Vote for the Most Valuable Expert

It’s time to recognize experts that go above and beyond with helpful solutions and engagement on site. Choose from the top experts in the Hall of Fame or on the right rail of your favorite topic page. Look for the blue “Nominate” button on their profile to vote.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now