-
November 13th, 2009, 05:50 AM
#1
URGENT!! only one connection per site
Hi.
I've got an simple WebSite made in asp.net with c#
The web make this:
Open connection (keep for the same session)
make an simple select
Close connection (when logout)
I need to know if it is posible to have only one connection per every sessions we make.
you know: if connection==close
open conection
else
get connection
use conecction
if louout and I0m the last connection
close connection
end
Somethig like that
Thanks...it's very urgent
-
November 13th, 2009, 03:03 PM
#2
Re: URGENT!! only one connection per site
I guess you haven't heard of a connection pool till now. There is no need to keep a connection open. Open the connection, do your work, close it and when you try to open it next again it will be picked up from the connection pool.
-
November 16th, 2009, 05:42 AM
#3
Re: URGENT!! only one connection per site
Even with connection pooling, there's a performance benefit in keeping a connection open manually if you need to do a lot of work over a short time.
However in the scenario outlined in the OP I would never, ever, advice keeping the connection open for that long, because you can quickly run out of connections, and it is very difficult in knowing when the user logs out. What if the user just closes the browser but does not select "log out" for example? Then you'll in theory never know he's logged out, and it's still consuming a connection.
So - in this case, I'd agree with Shuja Ali above and let the connection pool handle it. Just use care in how many and when you call the database.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|