look at the code:
SqlTransaction trn=con.BeginTransaction();
cmd2.ExecuteNonQuery();
trn.Commit();
}
catch (Exception)
{
trn.Rollback("FirstTran");
}
finally
{
con.Close();
}
//
Transaction makes an atomic block and all of the code in the Block will be Commited or will be rolled back. That's why both of statments are rolled back.
About the primary key error:
INSERT INTO Table_1 (Column1, Column2)
VALUES(60,1)
If Column2 is not a PK or UK and if you have an ID that is identity(1,1) then you don't have any problem with Primary Key Error.
Check this link please:
http://support.microsoft.com/kb/238163[
^]