i want simple exlaination from you guyz that why we close the datareader object
like
datareader dr = new datareader;
//assume that some code is here.
dr.close();
and when we close datareader object...
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Upendra Pratap ShahiPosted Sep 9, 2015, 1:37 AM
Munesh SharmaPosted Sep 9, 2015, 1:11 AM
Rojalin SahooPosted Sep 9, 2015, 12:56 AM
Karthikeyan KPosted Sep 8, 2015, 11:31 PM
Karthikeyan KPosted Sep 8, 2015, 11:28 PM
Remarks
You must explicitly call the Close method when you are through using the SqlDataReader to use the associated SqlConnection for any other purpose.
The Close method fills in the values for output parameters, return values and RecordsAffected, increasing the time that it takes to close a SqlDataReader that was used to process a large or complex query. When the return values and the number of records affected by a query are not significant, the time that it takes to close the SqlDataReader can be reduced by calling the Cancel method of the associated SqlCommand object before calling the Close method.
Do not call Close or Dispose on a Connection, a DataReader, or any other managed object in the Finalize method of your class. In a finalizer, you should only release unmanaged resources that your class owns directly. If your class does not own any unmanaged resources, do not include a Finalize method in your class definition. For more information, see Garbage Collection.