Difference between sqlconnection.close() and sqlconnection.dispose()

Home Forums Database Sql Server Difference between sqlconnection.close() and sqlconnection.dispose()

This topic contains 0 replies, has 2 voices, and was last updated by  Hirendra Sisodiya 4 years, 11 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #4614

    Shalabh
    Participant

    What is the difference between sqlconnection.close() and sqlconnection.dispose() ?

    #4616

    Both works differently in some scenerio and some time not. In order to SQL connection Close and Dispose are not the same thing. As we know Dispose() will completely releases resources, so the instance of the sql connection can’t be used again. If you will use the object of the sql connection after calling you’ll get an ObjectDisposed exception. On the other hand, SqlConnection.Close is similar, but enables you to reuse the same instance later. Dispose() will also include the Close() method

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.