A SQL Question

  • Thread starter Thread starter Blacky
  • Start date Start date
B

Blacky

Hi

I'm writing an app that connects to SQL Database, in this case MySQL. With a
select statement I'm getting to values from a tableand displaying them in a
list box. When changing the selection in the list box, I'll be retreiving
more value from that tables but only the record selected in the list box.

I would like to know the pro's and con's of the following.

Should I keep the connection open after I have retrieved the info for the
list box, then use the same connection every time I retrieve a specific
record(details)? Or should i close the connection after filling the list
box, and open a new connection everytime I retrieve the specific record?

Kind Regards
Nick
 
Blacky said:
I'm writing an app that connects to SQL Database, in this case MySQL. With a
select statement I'm getting to values from a tableand displaying them in a
list box. When changing the selection in the list box, I'll be retreiving
more value from that tables but only the record selected in the list box.

I would like to know the pro's and con's of the following.

Should I keep the connection open after I have retrieved the info for the
list box, then use the same connection every time I retrieve a specific
record(details)? Or should i close the connection after filling the list
box, and open a new connection everytime I retrieve the specific record?

Always close the connection after you've done an operation - the
underlying layer will handle pooling etc for you.
 
Back
Top