This article explains about the SQL Transaction and need of this transaction. The SQL transaction is used to control the database access. The namespace of SQL transaction is System.Data.SqlClient.
The transactional statements can be two types. They are,
- Commit
- Rollback
Commit:
The commit statement is used to commit the data as it is. That is the data changes can be committed for the current transaction.
Rollback:
The rollback statement help you to rollback all the changes for the current transaction.
Let see the transactions with an example.
"System.Data.SqlClient" this is the namespace for SQL transaction.
Start the transaction like
SqlTransaction trasaction=connection.BeginTransaction();
try
{
con.Open();
//to
begin the trancation
trasaction
= con.BeginTransaction();
//call
stored procedure
SqlCommand oc = new SqlCommand("detail",
con);
oc.CommandType
= CommandType.StoredProcedure;
oc.Transaction
= trasaction;

Join the conversation! Your thoughts help the community grow.