I am opening a connection to a database in which I need to issue multiple deletes before closing the connection. I have the following code but it looks strange with all the using statements. Is there a better way to do this? Is this the correct way to use the using statement with connections/commands?
using(OracleConnection oracleConnection = new OracleConnection(connectionString))
{
string table1Command= "DELETE FROM TABLE1...";
using(OracleCommand oracleCommand = new OracleCommand(table1Command, oracleConnection))
{
oracleCommand.ExecuteNonQuery();
}
string table2Command= "DELETE FROM TABLE2...";
using(OracleCommand oracleCommand = new OracleCommand(table2Command, oracleConnection))
{
oracleCommand.ExecuteNonQuery();
}
}