Posted by: Jeff Luther
You could write a CDK utility to parse an appl. and look for mis-matching,
though it might only get close, since a disconnect might well be in another
function, say, than where the connect is. But that would be a separate appl.
itself and not some underlying CDK code that ran below your appl.
Years ago I helped rewrite a SQLBase-only appl. to be able to support connects
to Oracle and SQL Server, and the basic way we attacked that problem was to
have all SQL calls go through a series of functions we wrote that parsed
the incoming generic sql, changed the sql depending on the backend and passed
it on so it was compatible with that db.
** Save your appl. to a new name before making changes below! **, then...
If it were me with your issue, I would consider writing a function that replaced
your connect/disconnect calls and wrote to a log/trace file of what and where
a call was made, and kept track of non-balanced connects/disconnects. Write the
function so that a replace of "SqlConnect(" and "SqlDisconnect(" could be done
with extra parms. and a minimum of effort. Maybe a function like:
Boolean: bConnect ! T = connect, F = disconnect
String: sCalledFrom ! like "myFunct" or "SAM_Create" value-could be a # parm.
Sql Handle: hSql
Now, based on a global (unless it's another parm.) bool. and global file handle
you can write out whether connect or disconnect, and where the call was made,
etc. Then, based on bConnect...
Return SqlConnect( hSql )
Return SqlDisconnect( hSql )
To change your appl. you would Replace:
"SqlConnect(" --> "SqlConnectMgr( TRUE, \'\',"
and that should replace "SqlConnect( hSql )"
with "SqlConnectMgr( TRUE, '', hSql )"
For disconnect, Replace:
"SqlDisonnect(" --> "SqlConnectMgr( FALSE, \'\', "
You would then need to find instances of "" and by hand edit
those to add in tokens like "SAM_AppStartup", "SAM_AppExit", "frmMain-SAM_Create"
and so on. If you have hundreds of these to edit, you could use the CDK
to parse your changed appl. and depending on the code level at the moment,
change "" to the current msg, function name, etc.
A CDK utility could be written to do this entire process for you--and if you
have may appls. it might be worth it to--but unless you know the CDK the
learning curve can be quite high and with a a single appl. to change the
manual method I described above would likely be easier.
If you don't know the CDK I have a small code sample on my web page link below.
Jeff Luther/PC Design