---
title: "SqlCommand with using statement"  
description: "SqlCommand with using statement"  
author: "Anonymous User"  
published: 2014-08-18  
updated: 2014-08-18  
canonical: https://www.mindstick.com/forum/2050/sqlcommand-with-using-statement  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# SqlCommand with using statement

I saw that in most samples [SqlCommand](https://www.mindstick.com/forum/91/difference-between-sqlcommand-and-sqlcommandbuilder) was used like this

```
using (SqlConnection con = new SqlConnection(CNN_STRING)){    using (SqlCommand cmd = new SqlCommand("Select ID,Name From Person", con))    {        SqlDataAdapter da = new SqlDataAdapter(cmd);        DataSet ds =new DataSet();       
da.Fill(ds);                   return ds;    }}
```

I know why we are using "using" statement. But SqlCommand doesn't inlcude [Close](https://yourviews.mindstick.com/story/1687/rubbing-hands-close-up-benefits)() [method](https://www.mindstick.com/forum/166/webservice-method), so should we really use it within using statement

## Replies

### Reply by Pravesh Singh

SqlCommand does implement IDisposable which a using statement will call .Dispose() on before the using block is finished. it's a good idea to call .Dispose() on an instance you are finished with i.e. it will clear up a database connection perhaps.


---

Original Source: https://www.mindstick.com/forum/2050/sqlcommand-with-using-statement

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
