To test my Atomic transaction, I wrote a Windows Form
application that used my Class Library. It simply got the ID and value for an
account and passed them to Transfer() method. This Windows Form application
must have a reference to System.EnterpriseServices as well.
Figure 4
This is the event handler for my btnTransfer button:
Listing 6
private void btnTransfer_Click(object sender, EventArgs e)
{
MyTransaction transaction = new MyTransaction();
try
{
transaction.Transfer(
Convert.ToInt32(txtID.Text),
Convert.ToInt32(txtValue.Text),
"Data Source=localhost;Initial "
+ "Catalog=AtomicTransaction;"
+ "Integrated Security=True;Pooling=False");
}
catch (Exception ex)
{
throw ex;
}
MessageBox.Show("Finished!");
}