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

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.