Is this possible using a using statement C# SQL?
private static void CreateCommand(string queryString,
string connectionString)
{
using (SqlConnectio
Just write it out explicitely:
SqlConnection connection = new SqlConnection(connectionString);
try
{
using (SqlCommand command = new SqlCommand(queryString, connection))
{
command.Connection.Open();
command.ExecuteNonQuery();
}
}
catch (Exception e)
{
// ...handle, rethrow. Also, you might want to catch
// more specific exceptions...
}
finally
{
connection.Close();
}