Transaction processing in ASP database

Source: Internet
Author: User
Transaction Processing | data | Database ASP transactions

by Chris Payne Introduction

Transactions are important to maintain data integrity, among other things, and have been with
Databases for some. Luckily, transactions aren ' t restricted to databases-you can use them in
Active Server Pages as, and without have to create custom components using Microsoft Transaction
Server (MTS). This article would take a look at the What transactions are, how they'll help ASP developers,
And how to implement them.

What are transactions?

Before we dive into the meat and we have to understand the terminology (believe me, I am lost for a long
Time because no one explained this terms to me).

Basically, using a transaction means it ' s an all-or-none deal. No halfways, no maybes. Let ' s suppose
You ' re modifying a database, and your have to add new items, one in a time. Before adding each item,
However, you have to check to make sure it fits certain criteria-if it doesn ' t, then your database
Cries, you receive an error, and the process quits. It May is desirable to quit halfway-for whatever
Reason, you are either want all the new rows or none of them.

Enter transactions. If you put the process in a transaction, and if a error occurs, the transaction
Would ' roll back ' to a ' just before you started your process. Thus, if any of the new items doesn ' t
Meet the criteria, none of the items gets added, instead of the the only-the-only-few.

The classic example is a banking application. Suppose someone wants to transfer funds from one
Another. You are would deduct X amount from Account A, and then add it to account B. Suppose
Deducted the money from account a (and before for you add it to account B), notice a problem (perhaps
Account B has restrictions, or isn't available for some reason). If the application just quits
Some error message, then account A is in the incorrect state, meaning it has funds. These
Funds are not in account B yet, so they are just floating out in cyberspace, and you have one very unhappy
Customer. With transactions, should your encounter this error, the process would roll back to a previous
State, and the money would automatically go back to where it started. If There are no problems, however,
The transaction would commit, and everything'll go through.

Another example more apropos to Web development is user registration. Suppose a user comes to your
Community Building Web site and decides to register. Once They submit their information, you are have to enter
it into the a database, and also set up their personal web page. Thus, every user in the database must have a
Personal Web page as, or no one would ever know that they are there. Your ASP script adds the user
Into the database perfectly, but a server error causes your Web page building routine to fail
Unexpectedly. You are have a floating user-a user in the database, but without a Web page. If this
Process were transactional, you could roll back to just before your inserted the user into the database
(thereby eliminating the floating user problem), and gracefully display a nice error message to the user.
Pretty slick, huh?

So how do I does it help Me?

It ' s always got to be about ' me, ' doesn ' t it? So, if you are didn ' t gather it from above, transactions are
Mainly used for error handling. They stop you to getting in weird positions so can ' t get out of by
Easily allowing you to ' undo ' the changes ' ve made. As you develop-more complex web
Applications, the need for strong State protection to become increasingly.

What is MTS?

MTS is Microsoft ' s answer to transactions. We won ' t go into too much detail, and but MTS is the engine
That is keeps track of object states, and rolls them back or commits when them. Even though it
Won ' t be apparent into your ASPs, MTS is, working busily behind the scenes to keep track of what you ' re
doing.

MTS requires all objects the use transactions to is registered in MTS. IIS itself has many different
components that process Web applications which are all registered with MTS, which is why ASPs can run
Transactionally through MTS, invisible to the user (and sometimes to the developer). So just trust us
We say you need MTS.

Note:though MTS is installed with Windows NT, it usually are not set up to run automatically. Therefore,
Before running any of the examples below, make sure the MTS service (MSDTC) are running (in the services
Contr



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.