Interviews15 answers
when connection will close in disconnected architecture if I dont use conobject.close() method?
15 Answers
You must use: using ( SqlConnection oCnn = new SqlConnection())
{
// your code here
} // in the last line of the using the connection 'll be closed.
If you do not close your connection, your Project will run slowly across multiple user scenarios.
Jefferson S. MottaPosted Jul 25, 2018, 8:48 AM EDT
use try{} ,catch{}, final{} ,or use "using{}"
Suresh KumarPosted Oct 28, 2017, 12:40 AM EDT
con.disposed()
Ganesh KhardePosted Oct 16, 2017, 4:00 AM EDT
by the use of using block
like using{
}
Mukesh KumarPosted Aug 23, 2017, 4:46 AM EDT
Its depend on code if use DataAdapter then this will auto open and close on .fill command. In other case when you use conobj.open() and execute some query and do not close the connection then its depend on connection time out property.
Gopal SharmaPosted Jul 27, 2017, 10:20 PM EDT
No need to explicitly open and close the connection in disconnected architecture.
Deepak KumarPosted Jul 26, 2017, 10:54 AM EDT
After completion of the main method.
Vishnu ReddyPosted Jul 17, 2017, 2:54 AM EDT
no need to close the connection
Rajkiran SwainPosted May 15, 2017, 2:56 AM EDT
finally
{
if (cn != null && cn.State == System.Data.ConnectionState.Open)
{
cn.dispose();
}
}
Rajavel GPosted May 11, 2017, 9:52 PM EDT
You don't need to close the connection... It will automatic open and close the connection when needed.
Dharmraj ThakurPosted May 2, 2017, 1:48 AM EDT
we can use statement
using(sqlconnection con=new sqlconnection())
{
}
Suresh MolabantiPosted Apr 24, 2017, 11:15 PM EDT
we can use statement
using(sqlconnection con=new sqlconnection())
{
}
Suresh MolabantiPosted Apr 24, 2017, 11:15 PM EDT
once your connection is Open which is paramount then closing it should not be a necessity. because there are sometimes that you will even forget to close your connection and your code will still run. so its not compulsory
Lawrence PetersPosted Apr 24, 2017, 7:11 AM EDT
Disconnected architecture means, you don’t need to connect always when you want to get data from the database. You do not need to open the connection explicitly. Once we fill data in dataset or datatable using fill method , the connection gets closed automatically.
Bhola ParitPosted Apr 4, 2017, 10:25 PM EDT
if you dont use conobject.close() method connection will close (in disconnected architecture) if it sat idle for certain period of time automatically.
Sulekh KumarPosted Mar 28, 2017, 12:53 AM EDT










