none
SqlConnection do i have to close ? RRS feed

  • Question

  • Hello,

     

    I'm developing a pocket application wich goes a lot on database !!

    my question is can i open a connection when user log-in and close only log-out ???

    is there a problem ??? i think is gonna be faster.... am i correct ?

     

    tks

    Thursday, August 23, 2007 10:57 PM

Answers

  • no

     

    you must close the connection once you have used it. SQL connections and operations are expensive and should be closed to avoid lagging and memory issues too. In addition, it gives the other applications that require SQL a chance to connect if the SQL has as much of the connections in its pool so it is best practice to ONLY use the database WHEN you require to as well as closing the connection straight after using it.

     

    you must close and dispose of the connection object once you have used it

     

    Thursday, August 23, 2007 11:16 PM
  • It is better to close the connection once your work is over.

    Thanks and Regards
    Baba
    Friday, August 24, 2007 5:43 AM

All replies

  • no

     

    you must close the connection once you have used it. SQL connections and operations are expensive and should be closed to avoid lagging and memory issues too. In addition, it gives the other applications that require SQL a chance to connect if the SQL has as much of the connections in its pool so it is best practice to ONLY use the database WHEN you require to as well as closing the connection straight after using it.

     

    you must close and dispose of the connection object once you have used it

     

    Thursday, August 23, 2007 11:16 PM
  • It is better to close the connection once your work is over.

    Thanks and Regards
    Baba
    Friday, August 24, 2007 5:43 AM