Nååh.... ja... det skal også foregå i samme transaktion for at du skal være helt sikker:
SqlCommand myCmd = new SqlCommand();
myCmd.Connection = myCon;
myCmd.CommandType = CommandType.Text;
myCmd.CommandText = "insert into mytable(....) values(....);select cast(SCOPE_IDENTITY() as int) as ID";
int returnid = (int)myCmd.ExecuteScalar();
dvs, det skal adskilles med et semikolon, for at eksekvere mere sql i samme transaktion.
(¯`·._.·[Brian Hvarregaard]·._.·´¯)