Is it necessary to put a Transaction around Manual SQL commands in c#?
I have the Situation where I have a Long running command which should either do it all or nothing at all in essence. with Manual C# SQL Connections (thus not using entityframework) I'm not sure if I Need to put a Transaction around it to achieve this behaviour or If the commands effects automatically don't occur if any error Pops up during the commands execution.
using (SqlConnection connection = new SqlConnection(Properties.Settings.Default.ConnectionString))
{
connection.Open();
SqlCommand command = new SqlCommand();
command.Connection = connection;
command.CommandTimeout = 900; // Wait 15 minutes before a timeout
command.CommandText = "INSERT ......";
command.ExecuteNonQuery();
}