Skip to content

IDisposable SqlCommand #1541

@KSib

Description

@KSib

I noticed that SqlCommand implements IDisposable (or rather DbCommand does and SqlCommand inherits from DbCommand), but in some instances in the docs I've seen SqlCommand is not wrapped in a using statement. Is there a reason for this? Maybe we are trusting SqlConnection to garbage collect the resources of SqlCommand?

Is it not a problem if SqlCommand isn't wrapped in a using? It seems I always see SqlConnection wrapped in a using; however, so I assume that's quite important.

Thanks.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions