Do we need to close connection when we use strongly typed table adapters?

P

Peter Bradley

Ysgrifennodd Max2006:
Hi,

I saw the Business Logic Layer pattern suggested at the following link and I
found that the pattern never closes the connection:

http://www.asp.net/learn/dataaccess/tutorial02cs.aspx?tabid=63

I am using strongly typed datasets and TableadApters. I assume that
TableadApters always closes the connections automatically. Is that correct
assumption?

Any help would be appreciated,,
Max

As far as I know you never need to close a connection if you use any
kind of DataAdapter (with a DataSet, of course). I am not aware that it
does any harm, though.

HTH



Peter
 
S

Steven Cheng[MSFT]

Hi Max,

I agree with peter that you do not need to explicitly control the open and
close for the SQL connections when using DataAdapter. The dataAdapter's
internal code logic will help you control the connection's open and close.
It is only when you use SqlCommand to return DataReader resultset will you
need to take care of the connection and reader's open and close.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 
S

Steven Cheng[MSFT]

Hi Max,

How are you doing? Have you got any further idea on this? If there is
anything else need help, please don't hesitate to post here.

Sincerely,

Steven Cheng

Microsoft MSDN Online Support Lead


This posting is provided "AS IS" with no warranties, and confers no rights.
 
M

Max2006

Hi Steven,

Thanks for followup. I am not explicitly closing the connection when I use
TableAdapter and monitored the connections to database through SQL Profiler.
Everything is working perfect! Thank you
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top