CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2003
    Posts
    56

    Question 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

  2. #2
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    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.

  3. #3
    Join Date
    Feb 2005
    Location
    Denmark
    Posts
    742

    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
  •  





Click Here to Expand Forum to Full Width

Featured