SQLConnection

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a single Windows form, in which I am using a connection object. I need the connection in many places in the form to execute commands. I need to know which of these is a better option and why
1. open and close the connection whenever i execute a command
2. pen the connection in the beginning, keep the connection open till i complete all my activites, close it at the end.
 
Hi Jnanesh,

Always think if you are processing on the internet, that makes your
decissions in this simple.

When you have a dataadapter which has only one table, you even have not to
open or to close it, it will be done.

When you use a datareader I keep it open untill al commands are done for
that perticulary read process and close it than again.

Just my idea about it,

Cor
I have a single Windows form, in which I am using a connection object. I
need the connection in many places in the form to execute commands. I need
to know which of these is a better option and why.
1. open and close the connection whenever i execute a command.
2. pen the connection in the beginning, keep the connection open till i
complete all my activites, close it at the end.
 
Hi Sandie,
I had this explained to me as a example of a door. When you open and close
a door more often, the door gets worn out and then you have problems later.
I have always opened the connection and left it open until I the form is
finished.

You have always your door open?

I see you are lucky, you live in a safe area.


Cor
 
Back
Top