Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How determine if custom trans object is connected?

320 views
Skip to first unread message

Rick

unread,
Jan 11, 2008, 3:36:45 PM1/11/08
to
How can I determine if a certain local custom transaction object I
create at runtime is connected to its data source? I originally thought
I could test its .SQLCODE property for a value of 0, but I notice that
immediately after I CREATE the transaction object its .SQLCODE property
is already 0. Thanks.

Brad Wery[TeamSybase]

unread,
Jan 11, 2008, 3:43:53 PM1/11/08
to
One way is to check the returned value from the transaction object
DBHandle() function. Keep in mind that this can be unreliable. As soon
as you obtain a valid connection you will get a database handle. If the
database itself were to drop the connection your transaction object will
still have that handle and return it when calling DBHandle() (even
though it's not valid).

For a foolproof solution you would probably have to send a command to
the database. Something simple like "SELECT 1". If it errors, you're not
connected, if it's successful you are connected.

Try a combination of the two.

Brad

--

*********************************************************************************
www.PowerToTheBuilder.com

- Free, full featured database development tool for ASE and SQL Server
- Take control of your GUI with a free PB user control library
*********************************************************************************

Terry Voth [TeamSybase]

unread,
Jan 11, 2008, 3:46:42 PM1/11/08
to
DBHandle()>0 tells you if it has been connected. Like the docs say, it
can't tell you if the database connection has been lost.

Good luck,

Terry [TeamSybase] and Sequel the techno-kitten

--
*********************************
Build your vocabulary and feed the hungry
http://www.freerice.com
*********************************
Newsgroup User Manual
=====================
TeamSybase <> Sybase employee
Forums = Peer-to-peer
Forums <> Communication with Sybase
IsNull (AnswerTo (Posting)) can return TRUE
Forums.Moderated = TRUE, so behave or be deleted
*********************************

Sequel's Sandbox: http://www.techno-kitten.com
Home of PBL Peeper, a free PowerBuilder Developer's Toolkit.
Version 4.0.3 now available at the Sandbox
PB Futures updated Jan 2/2008
See the PB Troubleshooting & Migration Guides at the Sandbox
^ ^
o o
=*=

Jeremy Lakeman

unread,
Jan 11, 2008, 8:35:54 PM1/11/08
to

Because you have to attempt to connect the transaction object, then
you can check it's sqlcode.

Rick

unread,
Jan 12, 2008, 10:17:46 AM1/12/08
to
Thanks much for this. DBHandle() actually does exactly what I want. It
may not be able to tell if the db connection has been 'lost', but it
sure does return 0 right after a regular SQL DISCONNECT, and that's all
I need to check on.

In article <4787d5b2$1@forums-1-dub>, seq...@techno-kitten.com says...

0 new messages