If you are using enterprise library data access application block , you don't need to open or close connection explicitly, just call the appropriate method on the database object, it will execute the method and close the connection itself. The exception
is when you use reader , in that case you should use the using block.
Member
32 Points
458 Posts
How to find the database conection is open or not in enterprise library 4.1?
Mar 09, 2010 11:01 PM|pathipati|LINK
Hi,
How to find the database conection is open or not in enterprise library 4.1?
here i want if conection is open i need to close it
so i writen the code loke below, but for every tiime its not going to loop
if (command.Connection.State == ConnectionState.Open)
{
command.Connection.Close();
}
Member
540 Points
142 Posts
Re: How to find the database conection is open or not in enterprise library 4.1?
Mar 10, 2010 02:10 AM|rakesh_nits|LINK
If you are using enterprise library data access application block , you don't need to open or close connection explicitly, just call the appropriate method on the database object, it will execute the method and close the connection itself. The exception is when you use reader , in that case you should use the using block.
have a look at this article
managing connections
http://msdn.microsoft.com/en-us/library/dd203181.aspx
also see the key scenarios, you will see that they are not opening or closing the connection explicitly any where.
http://msdn.microsoft.com/en-us/library/dd203113.aspx
it’s about learning how to dance in the rain!
Member
32 Points
458 Posts
Re: How to find the database conection is open or not in enterprise library 4.1?
Mar 10, 2010 03:51 AM|pathipati|LINK
thank you