Hi David;
FWIW: I have encountered this situation in the past with various DBMS where the DBA has set a low "inactivity" timeout setting that automatically disconnects the App(s) when the user minimizes the app for long periods of time or just locks the PC and walks away for a meeting, lunch, etc.
I tried to first resolve this situation like you and thought about how to re-establish the DB Connection again and then reset all the DWO's SetTransObject() pointers again. However, once you think about that aspect in more detail, you quickly realize that this is not a trivial programming task. Especially, when you have update business transactions in progress. :-(
My final solution was to use a "preventative" design like many Application Servers do where, the DBMS connection(s) are kept alive via pinging the DBMS on a regular basis in order to not let the "inactivity" DBMS timer expire. Of course, we also tried convincing the DBA's to turn this "inactivity" setting off (infinite wait) but in most shops, that was met with a resounding NO or bold laughter. ;-)
The "DB Ping" feature of App Servers is also commonly known as a "Heart Beat" feature. So what I did was implement this in a PB App and low and behold, the DBMS disconnects completely disappeared! Once that worked, I went one step further and implemented this as a "Heart beat" DB feature in my framework. You can see it at work here in my Demo App's log, as follows:
The HB feature is controlled by the App's Transaction Object's properties, as follows:
My framework extends the properties of PB's Transaction object class to allow the PB developer to set the heartbeat criteria. Thus, each TO that connects to the same and/or different DBMS / DB combination can have it's own HB specific settings.
When the framework sees that the "ib_heartbeat_required" Boolean flag is ON, it automatically starts a "Timing" object for the period as defined in the "il_heartbeat_time" property. When the Timing Object reaches the timer limitation, it sends an "oe_heart_beat" event to the TO. The TO responds by performing an "Execute Immediate" using the SQL in the "is_heartbeat_sql" property.
Note that the TO does not perform this HB action if between HB's, any SQL is sent out by the App. This DML activity resets the HB timer for each SQL sent. Also, if the HB fires and the App is waiting for a long result set, the HB feature will also not fire.
If you like this approach and want to look deeper into this implementation. Please check out the "Heart Beat" feature used by OrderEntry Demo App built from the STD Integrated framework. FYI: https://sourceforge.net/projects/stdfndclass/files/Applications/PowerBuilder/OrderEntry
HTH
Regards ...Chris