I\'ve got a problem, and all articles or examples I found seem to not care about it.
I want to do some database actions in a transaction. What I want to do is very s
SqlConnection conn = null;
SqlTransaction trans = null;
try
{
conn = new SqlConnection(_ConnectionString);
conn.Open();
trans = conn.BeginTransaction();
/*
* DB WORK
*/
trans.Commit();
}
catch (Exception ex)
{
if (trans != null)
{
trans.Rollback();
}
return -1;
}
finally
{
if (conn != null)
{
conn.Close();
}
}