M
Manoj Misran
I checked lot of posts on this topic and found a common consent of
everyone (including Microsoft) that
--one should open the connection as late as possible and close it ASAP
after he is done.
--Keep the connection open for a minimal period of time.
--Try to use disconnected database approach using DataSets as oppose
to DataReader.
Now, keeping these things in mind I want to plan my database layer.
Earlier I was having a global static connection object that I used to
open at the start of the application and close just before exiting. It
is an MDI application and has about 30 forms and all of them use
extensive database operations.
Now I am planning to change the connection strategy according to these
suggestions. I have one last concern, appreciate if someone can help
me.....
Can I still use the same global static connection object that I create
when application start and just open() and close() the same in all my
forms when I do any DB operations. Or should I even create a new
connection object everytime I open a form.
What my thought is, creation of connection object and just creating a
reference should not hold the connection if we close it properly after
the use and reopen the same connection reference when we need it. Will
it have any impact on the performance. Why I want to go this route is
because I am using this connection at many places and it will be a
major change if I need to remove this static connection object.
Otherwise I just have to open and close the same without worrying
about redefining the same in every form.
But either way I want to know what is the best approach.
Thanks in advance
everyone (including Microsoft) that
--one should open the connection as late as possible and close it ASAP
after he is done.
--Keep the connection open for a minimal period of time.
--Try to use disconnected database approach using DataSets as oppose
to DataReader.
Now, keeping these things in mind I want to plan my database layer.
Earlier I was having a global static connection object that I used to
open at the start of the application and close just before exiting. It
is an MDI application and has about 30 forms and all of them use
extensive database operations.
Now I am planning to change the connection strategy according to these
suggestions. I have one last concern, appreciate if someone can help
me.....
Can I still use the same global static connection object that I create
when application start and just open() and close() the same in all my
forms when I do any DB operations. Or should I even create a new
connection object everytime I open a form.
What my thought is, creation of connection object and just creating a
reference should not hold the connection if we close it properly after
the use and reopen the same connection reference when we need it. Will
it have any impact on the performance. Why I want to go this route is
because I am using this connection at many places and it will be a
major change if I need to remove this static connection object.
Otherwise I just have to open and close the same without worrying
about redefining the same in every form.
But either way I want to know what is the best approach.
Thanks in advance