What is the significance of commandbehavior.closeconnection




















CloseConnection does is close the underlying connection whenever the reader is closed. It is quite easy to forget to close database connections, and thereby waste resources that may be quite scarce, leading to serious application availability and stability issues.

Remediation Use theCommandBehavior. CloseConnection call style when calling the ExecuteReader method. StoredProcedure; sqlComm. Bit ; sqlComm. Parameters[" bitSomeResult"]. When using the SqlDataReader , you can read a column value only once. Feedback will be sent to Microsoft: By pressing the submit button, your feedback will be used to improve Microsoft products and services.

Privacy policy. Skip to main content. This browser is no longer supported. Download Microsoft Edge More info. Contents Exit focus mode. Data Assembly: System. Provides a description of the results of the query and its effect on the database. Note Use SequentialAccess to retrieve large values and binary data. After two methods have been prepared, the two methods are called from the Main method to test each other.

To see if the SqlDataReader object returned from the method using commandbehavior. CloseConnection will automatically close its dependent database connection object while shutting down, which solves the dilemma of data access layer writing.

When a Xxxdatareader object is built with CommandBehavior. CloseConnection, the database connection is automatically closed when the Xxxdatareader object is closed. This article is an English version of an article which is originally in the Chinese language on aliyun. This website makes no representation or warranty of any kind, either expressed or implied, as to the accuracy, completeness ownership or reliability of the article or any translations thereof.

If you have any concerns or complaints relating to the article, please send an email, providing a detailed description of the concern or complaint, to info-contact alibabacloud. A staff member will contact you within 5 working days. Once verified, infringing content will be removed immediately.

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email. It is based on services provided by the ADO. NET provider model.

The following illustration provides a high-level view of the relationship. Your approach is a good start, but populating that dictionary should only be done once , as Ian says in a comment. I have a working example below, but you need to be aware that this approach does have a few problems. For example:. Also, just providing a Type tells you nothing of other constraints, like field size and precision.

Making the right decision is also about how the data is used in your application and how it is stored in the database.

CloseConnection in ExecuteReader. Asked 4 Months ago Answers: 5 Viewed 22 times.



0コメント

  • 1000 / 1000