September 7, 2005 at 8:04 am
Hi guys,
I am a VB6 developer. this is issue. in my programe (which connect to SQL DB when starts) i'm creating a temporary table when the user login to the system to track user logins and drop the table when he log outs. my problem is when ever the is a power failure the network is down and my program quits. but still in SERVER the connection is active so the temporary table is not droped. so when the user log in again. program is not allowin ghim to login 'cos the temp table is already there in his name. i have to kill the connection manually to allow him login...
How to resolve this issue.
Please help
Thanks in advance
Rifky
September 12, 2005 at 8:00 am
This was removed by the editor as SPAM
September 13, 2005 at 8:24 am
The problem that you are running into is that of an orphaned session. Since the application program was not able to communicate cleanly to SQL Server, the engine was not able to clean up the server process. Orphaned sessions get resolved by the engine based on the registry settings depending upon which protocol is being used OR if those are explicitly killed by the admin. You can look up Orphaned Sessions in BOL for more information on that.
Regarding this issue, you can design it such that you do session management in a physical table in the database like say WEB_SESSION table. Besides the normal fields that you want in that table, you can have a field that tracks session timeouts i.e. after what time do you want the user to not have access in case of a network/power failure. That way, when your program logs a user in, it can first check whether the user still is within that limit and allow him/her to log-on...if not, then the user is requested to re-log back in the system since the session has expired. There are also a lot of other things that you will be able to design around security and session management if you do it this way like tying it up with users/roles/groups and other entities in the system.
And if you do this, then please remember to have a purge SQL job to remove old enteriees from this table (this could be a SQL job that runs every night on the database server and removes enteries say that are older than a day)
Hth
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply