1: cs.Open();2: SqlTransaction tr = cs.BeginTransaction();3: try
4: {5: SqlCommand trc = new SqlCommand("", cs, tr);
6: trc.Transaction = tr;7:8: //input member
9: trc.Parameters.Add("@nama", SqlDbType.VarChar,50).Value = TxtNama.Text;
10: trc.Parameters.Add("@alamat", SqlDbType.VarChar,50).Value = TxtAlamat.Text;
11: trc.CommandText = "INSERT INTO tMember VALUES (@nama,@alamat)";
12: trc.ExecuteNonQuery();13:14: //delete temp member
15: trc.Parameters.Add("@idMember", SqlDbType.Int).Value = LId.Text
16: trc.CommandText = "DELETE FROM tTempMember WHERE idMember=@idMember";
17: trc.ExecuteNonQuery();18: tr.Commit();19:20: }21: catch (SqlException ex)
22: {23: tr.Rollback();24: MessageBox.Show("Delete roll back due to " + ex.Message);
25: }26: cs.Close();27: ds.Clear();28: daSel.Fill(ds);
Minggu, 25 September 2011
Contoh Layout Source Code
Langganan:
Postingan (Atom)