Transaction in .NET

Atransactionrepresents a code or a set of procedures or components that should be executed as a unit. All the methods in transaction should be executed successfully otherwise the complete unit will fail. A transaction can also be described to cover theACID propertieswhich Stands for:

Atomicity

Consistency

Isolation

Durability

Transfer Funds Sample

We will builds the sample ofASP.NETweb formfor the fictitious bank which can transfer a particular amount from one account to another, when the balance of first account is sufficient to cover this transfer.

mission critical applications.

Where

Transaction Programming Models of .NET 1.x

An Explicit transaction management programming model is offered by ADO.NET 1.0. The developer is responsible for explicitly starting and managing the transaction, as shown in Example above.

Explicit transaction management in ADO.NET

string connectionString = "...";

IDbConnection connection = new SqlConnection(connectionString);

connection.Open();

IDbCommand command = new SqlCommand();

command.Connection = connection;

IDbTransaction transaction;

transaction = connection.BeginTransaction(); //Enlisting database

command.Transaction = transaction;

try

{

/* Interact with database here, then commit the transaction */

transaction.Commit();

}

catch

{

transaction.Rollback(); //Abort transaction

}

finally

{

connection.Close();

}

By which you obtains an object which represents the underlying database transaction by calling BeginTransaction() on the connection object.

BeginTransaction() returns an implementation of the interface IDbTransactionwhich is used to manage the transaction. If any error occurred, you need to abort the transaction by calling Rollback(). If all updates or other changes made to the database are consistent, simply callCommit() on the transaction object. While the explicit programming model is straightforward, it is most-suitable for a single object interacting with a single database

We atTranstutors.comare aware of the complexities of this topic, and therefore our onlinecomputer sciencetutors are available round the clock to help you. We offer a range of services

• Online homework help- to help students with the homework related to computer science

• Online assignment help– to help students with their assignments.

So if you are you in need of.NETHomework Help/ computer science AssignmentHelp? Our competent pools of computer science professionals are available 24*7 to give you a solution to your problem