What does Dispose method do with the connection object?
Answers were Sorted based on User's Feedback
Answer / abhishek
SqlConnection.Dispose - in addition to closing the connection, it also
clears stateful nature of the SqlConnection instance, like connection string
etc.Beneath this layer, in SqlConnection atleast, there is a connection
pooling mechanism, which eventually holds actual physical database
connections. Again, they aren't really unmanaged resources, but non .NET
resources nonetheless. Lest I cause any confusion SqlClient has TDS parsing
built into .NET code, so technically in this scenario - there wasn't any
unmanaged resource.
So in short, Dispose does not **have** to release unmanaged resources - and
by convention it does cleanup. Thats exactly what SqlConnection.Dispse
does - "clean up clean up everybody do your share"
| Is This Answer Correct ? | 3 Yes | 1 No |
What is difference between continue and break in c#?
Can destructors have access modifiers?
Why do we use hashtable in c#?
What are the ways to deploy an assembly?
Can you declare the override method static while the original method is non-static?
How objects are stored in memory?
What is the difference between as and is operators in c#?
Explain namespaces in c#.
How do you specify a custom attribute for the entire assembly (rather than for a class)?
Explain About delegates
Explain About Global.asax
How long does a loop recorder procedure take?
Visual Basic (800)
C Sharp (3816)
ASP.NET (3180)
VB.NET (461)
COM+ (79)
ADO.NET (717)
IIS (369)
MTS (11)
Crystal Reports (81)
BizTalk (89)
Dot Net (2435)
Exchange Server (362)
SharePoint (720)
WCF (340)
MS Office Microsoft (6963)
LINQ Language-Integrated Query (317)
WPF (371)
TypeScript (144)
Microsoft Related AllOther (311)