public void createUser(int pnr, string forename, string surname, string mUsername, string mPassword, string mRole, string passwordSalt, string userType) { //Set isolation level TransactionOptions ops = new TransactionOptions(); ops.IsolationLevel = System.Transactions.IsolationLevel.ReadCommitted; //Wrapp transaction using (TransactionScope trans = new TransactionScope(TransactionScopeOption.Required, ops)) { try { db.setProjectMember(pnr, forename, surname, mUsername, mPassword, mRole, passwordSalt, userType); db.SubmitChanges(); //Commit transaction trans.Complete(); } catch (SqlException e) { MessageBox.Show(e.Message.ToString()); } catch (TransactionAbortedException tab) { MessageBox.Show(tab.Message.ToString()); } catch (TransactionInDoubtException tib) { MessageBox.Show(tib.Message.ToString()); } } Console.WriteLine(pnr + forename + surname + mUsername + mPassword + mRole); }