L
Lau Lei Cheong
Hello,
Actually I think I should have had asked it long before, but somehow
I haven't.
Here's the scenerio: Say we have a few pages in an ASP.NET project,
each of them needs to connect to the database(Does not really matter but,
in case you need to know, either MSSQL or ODBC ones) a few times when it
loads to do the CURD things. How there's 3 ways proposed to do so:
1) Store the connection object in a class as static object. Each
time the page loads, it opens(in case connection disconnected) and wait
until the connection is avaliable. Not closing it and use it through the
session.
2) Store the connection object in the Page, open the connection when
the page loads, and close as the page renders.
3) New the connection object on "per use" basis. Declare the object
in the function blocks, Open and Close within try{}finally{} control block,
and let the GC frees it when the procedure exits.
Of the above designs, which one is most sound to you? And will that
impose heavier burden to the database? I don't have clear idea about it and
wish to clarify that before carrying on the next project. (Currently (3) is
selected as it seems neater)
Thanks for any inputs.
Regards,
Lau Lei Cheong
Actually I think I should have had asked it long before, but somehow
I haven't.
Here's the scenerio: Say we have a few pages in an ASP.NET project,
each of them needs to connect to the database(Does not really matter but,
in case you need to know, either MSSQL or ODBC ones) a few times when it
loads to do the CURD things. How there's 3 ways proposed to do so:
1) Store the connection object in a class as static object. Each
time the page loads, it opens(in case connection disconnected) and wait
until the connection is avaliable. Not closing it and use it through the
session.
2) Store the connection object in the Page, open the connection when
the page loads, and close as the page renders.
3) New the connection object on "per use" basis. Declare the object
in the function blocks, Open and Close within try{}finally{} control block,
and let the GC frees it when the procedure exits.
Of the above designs, which one is most sound to you? And will that
impose heavier burden to the database? I don't have clear idea about it and
wish to clarify that before carrying on the next project. (Currently (3) is
selected as it seems neater)
Thanks for any inputs.
Regards,
Lau Lei Cheong