Is it necessary for you to increment the userID from Database properties itself. Because what I am saying is, before inserting any records, just retrieve the last userID from database, store it in a integer variable and then increment it and insert back into database along with the new record.
Say your last user id was 9.
Use this query - Select max(userID) from "your table";
int x=0;
SqlDataReader dr=com.ExecuteReader();
if(dr.HasRows)
{
While(dr.Read())
{
x=Convert.ToInt32(dr.GetString(0).ToString);
}
}
x=x+1;
Now since you have new x
value, easily insert it back to database with new record.
So that auto increment will be followed and even though failure occurs insertion will not be done and UserID
does not increase.