Creating the UpdateReceipt Component

To implement the scenario for this section, you will build the UpdateReceipt component. You will also modify the Receipt component's Update method to use UpdateReceipt. Update adds 100 to the maximum receipt value stored in the database.

Click here to see the Update method

You also need to add code to the GetNextReciept method of the Receipt component to check whether the maximum receipt value has been reached. If so, the Update method is called.

Click here to see the GetNextReceipt method

To create the UpdateReceipt component
  1. Open the \MTx\Samples\Account.VB\Step7\Account.vbp project.
  2. Build the component as a dynamic-link library (DLL) and save it as \MTx\Samples\Account.VB\Step7\VBAcct.dll.

By adding a new class module, you add a new COM component to this DLL. Therefore, you need to delete the existing components in the Microsoft Transaction Server Explorer and then install the new components.

To reinstall your components
  1. Remove the Account, MoveMoney, CreateTable, and Receipt components from the Transaction Server Explorer.

How?

  1. Add the new components. Use the DLL you created in \MTx\Samples\Account.VB\Step7\VBAcct.dll.

How?

To set the transaction attributes for your components
  1. For the Account and MoveMoney components, set the transaction attribute to Requires a transaction.

How?

  1. For the Receipt component, set the transaction attribute to Does not support transactions. This is the default value.
  2. For the CreateTable and UpdateReceipt components, set the transaction attribute to Requires a new transaction.

The code you added here is similar to the code you added in "Building Transactional Components." However, choosing Requires a new transaction causes the UpdateReceipt component to run in a new transaction. The next section discusses how this affects application behavior.

See Also

Transactions, Transaction Attributes