SlideShare une entreprise Scribd logo
1  sur  31
Télécharger pour lire hors ligne
Developing Database Applications Using ADO.NET and XML
Objectives


                In this session, you will learn to:
                   Manage local transactions
                   Manage distributed transactions




     Ver. 1.0                      Session 10         Slide 1 of 31
Developing Database Applications Using ADO.NET and XML
Managing Local Transactions


                A transaction can be defined as a sequence of operations
                that are performed together as a single logical unit of work.
                If a transaction is successful, all the data modifications
                performed in the database will be committed and saved.
                If a transaction fails or an error occurs, then the transaction
                is rolled back to undo the data modifications done in the
                database.




     Ver. 1.0                     Session 10                            Slide 2 of 31
Developing Database Applications Using ADO.NET and XML
Properties of a Transaction


                For a transaction to commit successfully within a database,
                it should possess the following four properties:
                  Atomicity      States that either all the modifications
                                  are performed or none of them are
                                  performed


                  Consistency    States that data is in a consistent state
                                  after a transaction is completed
                                  successfully to maintain the integrity of
                                  data

                  Isolation      States that any data modification made
                                  by one transaction must be isolated from
                                  the modifications made by the other
                                  transaction

                  Durability     States that any change in data by a
                                  completed transaction remains
                                  permanently in effect in the database



     Ver. 1.0                    Session 10                                   Slide 3 of 31
Developing Database Applications Using ADO.NET and XML
Types of Transaction


                ADO.NET provides support for two types of transactions:
                   Local transactions          A local transaction performs on a single
                                               data source. Because local transactions
                                               are performed on a single data source,
                                               these transactions are efficient to
                                               operate and easy to manage.


                                               A distributed transaction performs on
                   Distributed transactions    multiple data sources. Distributed
                                               transactions enable you to incorporate
                                               several distinct transactional operations
                                               into an atomic unit that either succeed or
                                               fail completely.




     Ver. 1.0                     Session 10                                   Slide 4 of 31
Developing Database Applications Using ADO.NET and XML
Performing Local Transactions


                •   ADO.NET has an interface, IDbTransaction that
                    contains methods for creating and performing local
                    transactions against a single data source.
                •   The following table lists the transaction classes available in
                    the .NET Framework 2.0.
                     Types of Transaction Classes                 Description

                     System.Data.SqlClient.SqlTransaction         Transaction class for .NET framework
                                                                  data provider for SQL Server
                     System.Data.OleDb.OleDbTransaction           Transaction class for .NET framework
                                                                  data provider for OLE DB
                     System.Data.Odbc.OdbcTransaction             Transaction class for .NET framework
                                                                  data provider for ODBC
                     System.Data.OracleClient.OracleTransaction   Transaction class for .NET framework
                                                                  data provider for Oracle




     Ver. 1.0                            Session 10                                        Slide 5 of 31
Developing Database Applications Using ADO.NET and XML
Performing Local Transactions (Contd.)


                Let us understand how to create a local transaction.
                 string connectString =           Creating a connection to the
                                                  data source
                 "Initial Catalog=AdventureWorks;
                 Data Source=SQLSERVER01;
                 User id=sa;Password=niit#1234";
                 SqlConnection cn = new SqlConnection();
                 cn.Open();
                 cn = connectString;
                 SqlTransaction tran = null;




     Ver. 1.0                    Session 10                            Slide 6 of 31
Developing Database Applications Using ADO.NET and XML
Performing Local Transactions (Contd.)



                try
                {
                  tran = cn.BeginTransaction(); Calling the BeginTransaction()
                  SqlCommand cmd = new          method
                                                Creating the command object and
                  SqlCommand("INSERT INTO
                                                passing the SQL command
                  empdetails(ccode,cname,
                  caddress,cstate,ccountry,
                  cDesignation,cDepartment)
                  VALUES(1101,'Linda Taylor',
                  'Oxfordshire','London',
                  'UK','Manager','Finance')", cn, tran);




     Ver. 1.0                   Session 10                          Slide 7 of 31
Developing Database Applications Using ADO.NET and XML
Performing Local Transactions (Contd.)



                cmd.ExecuteNonQuery();
                                                 Committing the transaction if
                                                 the command succeeds
                tran.Commit();
                Console.WriteLine("Transaction
                Committedn)";
                }
                catch (SqlException ex)
                {                                Rolling back the transaction if the
                  tran.Rollback();               command fails

                  Console.WriteLine("Error
                  - TRANSACTION ROLLED BACKn"
                  + ex.Message);
                }


     Ver. 1.0                Session 10                               Slide 8 of 31
Developing Database Applications Using ADO.NET and XML
Performing Local Transactions (Contd.)



                catch (System.Exception ex)
                {
                  Console.WriteLine("System Errorn" +
                  ex.Message);
                }
                finally
                {
                  cn.Close();
                }
                Console.ReadLine();
                }
                }
                }

     Ver. 1.0                Session 10                  Slide 9 of 31
Developing Database Applications Using ADO.NET and XML
Just a minute


                Which method is called when a transaction succeeds in its
                operation?
                1.   Rollback()
                2.   Commit()
                3.   BeginTransaction()
                4.   ExecuteNonQuery()




                Answer:
                2. Commit()



     Ver. 1.0                    Session 10                        Slide 10 of 31
Developing Database Applications Using ADO.NET and XML
Demo: Managing Local Transactions


                Problem Statement:
                   John Howard, the HR executive has joined as a head of the
                   Finance department at Texas. Therefore, his details need to be
                   added to the HR database. The Department code for the
                   Finance department is D002. The user name that needs to be
                   assigned to him is JohnH and the password is howard.
                   As a part of the development team, you need to create a
                   transaction that will allow you to add these details in the
                   HRusers and Department tables.




     Ver. 1.0                     Session 10                            Slide 11 of 31
Developing Database Applications Using ADO.NET and XML
Managing Distributed Transactions


                •   Distributed transactions are performed on multiple data
                    sources or multiple connections within a data source.
                •   Distributed transactions are created in the
                    System.Transaction namespace.
                •   The System.Transaction namespace has a
                    TransactionScope class, which enables a developer to
                    create and manage distributed transactions.
                •   To create a distributed transaction, a TransactionScope
                    object is created in a using block.
                •   The TransactionScope object decides whether to create
                    a local transaction or a distributed transaction. This is
                    known as transaction promotion.



     Ver. 1.0                       Session 10                        Slide 12 of 31
Developing Database Applications Using ADO.NET and XML
Managing Distributed Transactions (Contd.)


                Let us understand how to create a distributed transaction.
                 using (TransactionScope ts           Creating the TransactionScope
                 = new TransactionScope())            object

                 {
                   using(SqlConnection cn             Creating a connection to the data
                   = new SqlConnection("Initial       source
                   Catalog=HR;Data
                   Source=SQLSERVER01;User
                   id=sa;Password=niit#1234"))
                   {
                     cn.Open();




     Ver. 1.0                    Session 10                               Slide 13 of 31
Developing Database Applications Using ADO.NET and XML
Managing Distributed Transactions (Contd.)



                using(SqlCommand cmd = new      Creating a SqlCommand object
                                                to insert a record in the
                SqlCommand("INSERT INTO
                                                HRusers table
                HRusers(cUserName,cPassword)
                VALUES('Darren','Cooper')", cn))
                {
                  int rowsUpdated =
                  cmd.ExecuteNonQuery();
                  if (rowsUpdated > 0)
                    {




     Ver. 1.0                   Session 10                        Slide 14 of 31
Developing Database Applications Using ADO.NET and XML
Managing Distributed Transactions (Contd.)



                SqlConnection cn1 = new     Creating another connection to the
                SqlConnection("Initial      same data source
                Catalog=HR;Data
                Source=SQLSERVER01;User
                id=sa;Password=niit#1234"))
                {
                  cn1.Open();
                  using (SqlCommand cmd1 = Creating another SqlCommand
                                            object to delete a record in the
                  new SqlCommand("DELETE
                                            Department table
                  Department WHERE
                  cDepartmentCode=1111", cn1))
                  {
                    int rowsUpdated1 =
                    cmd1.ExecuteNonQuery();


     Ver. 1.0                    Session 10                            Slide 15 of 31
Developing Database Applications Using ADO.NET and XML
Managing Distributed Transactions (Contd.)



                if (rowsUpdated1 > 0)
                {
                  ts.Complete();              Calling the Complete() method
                                              to commit the transactions
                  Console.WriteLine
                  ("Transaction Committedn");
                  cn1.Close();
                }
                }}}
                cn.Close();
                }}
                Console.ReadLine();
                }}}



     Ver. 1.0                   Session 10                         Slide 16 of 31
Developing Database Applications Using ADO.NET and XML
Just a minute


                The _______ method is invoked to commit the distributed
                transaction.
                1.   Commit()
                2.   BeginTransaction()
                3.   Complete()
                4.   Rollback()




                Answer:
                3. Complete()



     Ver. 1.0                   Session 10                        Slide 17 of 31
Developing Database Applications Using ADO.NET and XML
Performing Bulk Copy Operations in a Transaction


                •   Bulk copy operations can be performed as an isolated
                    operation or as a part of a transaction.
                •   By default, a bulk copy operation is its own transaction.
                •   To perform a bulk copy operation, you need to create a new
                    instance of BulkCopy class with a connection string.
                •   The bulk copy operation creates, and then, commits or rolls
                    back the transaction.




     Ver. 1.0                        Session 10                        Slide 18 of 31
Developing Database Applications Using ADO.NET and XML
Specifying Isolation Levels of a Transaction


                An isolation level determines the effect a transaction has on
                other transactions that are currently running, and vice versa.
                By default, all transactions are completely isolated and run
                concurrently without impacting each other.
                The isolation level of a transaction specifies the locking
                strategy used by the connection running the transaction to
                prevent concurrency problems when multiple transactions
                access the same data.




     Ver. 1.0                     Session 10                          Slide 19 of 31
Developing Database Applications Using ADO.NET and XML
Specifying Isolation Levels of a Transaction (Contd.)


                The following table describes the concurrency errors that
                can occur if multiple transactions access the same data at
                the same time.
                 Concurrency Error       Description
                 Dirty read              A transaction reads the data that has not been
                                         committed by the other transaction. This can
                                         create problem if a transaction that has added
                                         the data is rolled back.
                 Nonrepeatable read      A transaction reads the same row more than
                                         once and a different transaction modifies the row
                                         between the reads.
                 Phantom read            A transaction reads a rowset more than once
                                         and a different transaction inserts or deletes
                                         rows between the first transaction’s reads.




     Ver. 1.0                         Session 10                                          Slide 20 of 31
Developing Database Applications Using ADO.NET and XML
Specifying Isolation Levels of a Transaction (Contd.)


                The various types of isolation levels of a transaction are:
                    Read Uncommitted
                    Read Committed with Locks
                    Read Committed with Snapshots
                    Repeatable Read
                    Snapshot
                    Serializable




     Ver. 1.0                     Session 10                           Slide 21 of 31
Developing Database Applications Using ADO.NET and XML
Specifying Isolation Levels of a Transaction (Contd.)


                The following table describes the various isolation levels
                and the corresponding concurrency errors for a transaction.
                 Isolation Level    Dirty Read   Nonrepeatable Read   Phantom Read
                 Read Uncommitted   Yes          Yes                  Yes
                 Read Committed     No           Yes                  Yes
                 with Locks
                 Read Committed     No           Yes                  Yes
                 with Snapshots
                 Repeatable Read    No           No                   Yes
                 Snapshot           No           No                   No
                 Serializable       No           No                   No




     Ver. 1.0                       Session 10                                Slide 22 of 31
Developing Database Applications Using ADO.NET and XML
Specifying Isolation Levels of a Transaction (Contd.)


                Let us understand how to set the isolation level of a
                transaction to Read Committed.
                 TransactionOptions options = new    Initializing the
                                                     TransactionOptions
                 TransactionOptions();               object
                 options.IsolationLevel =            Setting the Isolation level of
                 System.Transactions.IsolationLevel. both transactions to Read
                                                     Committed
                 ReadC ommitted;
                 using(TransactionScope ts = new
                 TransactionScope
                 (TransactionScopeOption.
                 Required, options)){
                   using (SqlConnection cn = new     Creating a connection to
                                                     a data source
                   SqlConnection("Initial Catalog=
                   HR;Data Source=SQLSERVER01;
                   User id=sa;Password=niit#1234;")){
                     cn.Open();
     Ver. 1.0                     Session 10                            Slide 23 of 31
Developing Database Applications Using ADO.NET and XML
Specifying Isolation Levels of a Transaction (Contd.)



                using(SqlCommand cmd = new          Creating a SqlCommand
                                                    object to insert a record in the
                SqlCommand("INSERT INTO             Department table
                Department(cDepartmentCode
                ,vDepartmentName,vDepartmentHead,
                vLocation) VALUES(2013,'IT','Lara
                King','Houston')", cn)){
                  int rowsUpdated =
                  cmd.ExecuteNonQuery();
                  if (rowsUpdated > 0)
                  {




     Ver. 1.0                Session 10                            Slide 24 of 31
Developing Database Applications Using ADO.NET and XML
Specifying Isolation Levels of a Transaction (Contd.)



                using (SqlConnection cn1 =      Creating another connection to
                                                the same data source
                new SqlConnection("Initial
                Catalog=HR;Data
                Source=SQLSERVER01;User
                id=sa;Password=niit#1234"))
                {
                  cn1.Open();
                  using(SqlCommand cmd = new    Creating another command
                  SqlCommand("INSERT INTO       object to insert a record in the
                                                HRusers table
                  HRusers(cUserName,cPassword
                  ) VALUES('Hansel','Lord')",
                  cn1))




     Ver. 1.0                Session 10                                Slide 25 of 31
Developing Database Applications Using ADO.NET and XML
Specifying Isolation Levels of a Transaction (Contd.)



                {
                    int rowsUpdated1 =
                    cmd1.ExecuteNonQuery();
                    if (rowsUpdated1 > 0)
                    {
                      ts.Complete();           Calling the Complete() method
                                               to commit both transactions
                    }}}}




     Ver. 1.0                  Session 10                         Slide 26 of 31
Developing Database Applications Using ADO.NET and XML
Just a minute


                Which isolation level supports the occurrence of Dirty read,
                Nonrepeatable read, and Phantom read?
                 1.   Read Committed with Locks
                 2.   Serializable
                 3.   Read Committed with Snapshots
                 4.   Read Uncommitted




                Answer:
                 4. Read Uncommitted



     Ver. 1.0                      Session 10                        Slide 27 of 31
Developing Database Applications Using ADO.NET and XML
Demo: Managing Distributed Transactions


                Problem Statement:
                   Pamela Cruz has joined as an HR executive in Tebisco.
                   Therefore, her details that includes user name and password
                   needs to be inserted in the HRusers table. In addition, the
                   details about her position needs to be added in the Position
                   table. Both the operations need to be performed
                   simultaneously in both the tables. As a part of the development
                   team, you need to add the required details for Pamela in the
                   HR database.

                   Note: To enable execution of the distributed transactions, you
                   need to ensure that the MSDTC services are running on your
                   system.




     Ver. 1.0                     Session 10                             Slide 28 of 31
Developing Database Applications Using ADO.NET and XML
Summary


               In this session, you learned that:
                  A transaction is a logical unit of work that must be completed to
                  maintain the consistency and integrity of a database.
                  A transaction has the following properties:
                      Atomicity
                      Consistency
                      Isolation
                      Durability
                  The two types of transaction are:
                       Local transactions
                       Distributed transactions




    Ver. 1.0                         Session 10                           Slide 29 of 31
Developing Database Applications Using ADO.NET and XML
Summary (Contd.)


                A local transaction performs on a single data source. The
                 IDbTransaction interface contains methods for creating and
                 performing local transactions against a data source.
                A distributed transaction performs on multiple data sources. A
                 distributed transaction enables you to incorporate several
                 distinct transactional operations into an atomic unit that either
                 succeed or fail completely.
                Bulk copy operations can be performed as an isolated
                 operations or as a part of a transaction. By default, a bulk copy
                 operation is its own transaction.
                An isolation level determines the effect a transaction has on
                 other transactions that are currently running, and vice versa.




    Ver. 1.0                     Session 10                              Slide 30 of 31
Developing Database Applications Using ADO.NET and XML
Summary (Contd.)


               The various concurrency errors that can occur when multiple
               transactions access the same data at the same time are:
                 Dirty read
                 Nonrepeatable read
                 Phantom read
               The various types of isolation levels are for a transaction are:
                   Read Uncommitted
                   Read Committed with Locks
                   Read Committed with Snapshots
                   Repeatable Read
                   Snapshot
                   Serializable




    Ver. 1.0                   Session 10                               Slide 31 of 31

Contenu connexe

Tendances

Visual Basic.Net & Ado.Net
Visual Basic.Net & Ado.NetVisual Basic.Net & Ado.Net
Visual Basic.Net & Ado.NetFaRid Adwa
 
Introduction to ado
Introduction to adoIntroduction to ado
Introduction to adoHarman Bajwa
 
ADO.NET difference faqs compiled- 1
ADO.NET difference  faqs compiled- 1ADO.NET difference  faqs compiled- 1
ADO.NET difference faqs compiled- 1Umar Ali
 
Disconnected Architecture and Crystal report in VB.NET
Disconnected Architecture and Crystal report in VB.NETDisconnected Architecture and Crystal report in VB.NET
Disconnected Architecture and Crystal report in VB.NETEverywhere
 
Database programming in vb net
Database programming in vb netDatabase programming in vb net
Database programming in vb netZishan yousaf
 
PATTERNS07 - Data Representation in C#
PATTERNS07 - Data Representation in C#PATTERNS07 - Data Representation in C#
PATTERNS07 - Data Representation in C#Michael Heron
 
Graph db as metastore
Graph db as metastoreGraph db as metastore
Graph db as metastoreHaris Khan
 
JAM819 - Native API Deep Dive: Data Storage and Retrieval
JAM819 - Native API Deep Dive: Data Storage and RetrievalJAM819 - Native API Deep Dive: Data Storage and Retrieval
JAM819 - Native API Deep Dive: Data Storage and RetrievalDr. Ranbijay Kumar
 
Ado dot net complete meterial (1)
Ado dot net complete meterial (1)Ado dot net complete meterial (1)
Ado dot net complete meterial (1)Mubarak Hussain
 
Intake 38 data access 1
Intake 38 data access 1Intake 38 data access 1
Intake 38 data access 1Mahmoud Ouf
 

Tendances (20)

Visual Basic.Net & Ado.Net
Visual Basic.Net & Ado.NetVisual Basic.Net & Ado.Net
Visual Basic.Net & Ado.Net
 
Introduction to ado
Introduction to adoIntroduction to ado
Introduction to ado
 
Introduction to ado.net
Introduction to ado.netIntroduction to ado.net
Introduction to ado.net
 
Ado.net
Ado.netAdo.net
Ado.net
 
Ado.net
Ado.netAdo.net
Ado.net
 
ADO.NET difference faqs compiled- 1
ADO.NET difference  faqs compiled- 1ADO.NET difference  faqs compiled- 1
ADO.NET difference faqs compiled- 1
 
Disconnected Architecture and Crystal report in VB.NET
Disconnected Architecture and Crystal report in VB.NETDisconnected Architecture and Crystal report in VB.NET
Disconnected Architecture and Crystal report in VB.NET
 
Database programming in vb net
Database programming in vb netDatabase programming in vb net
Database programming in vb net
 
ASP.NET 09 - ADO.NET
ASP.NET 09 - ADO.NETASP.NET 09 - ADO.NET
ASP.NET 09 - ADO.NET
 
notes
notesnotes
notes
 
PATTERNS07 - Data Representation in C#
PATTERNS07 - Data Representation in C#PATTERNS07 - Data Representation in C#
PATTERNS07 - Data Representation in C#
 
6 database
6 database 6 database
6 database
 
Intake 38 10
Intake 38 10Intake 38 10
Intake 38 10
 
Graph db as metastore
Graph db as metastoreGraph db as metastore
Graph db as metastore
 
JAM819 - Native API Deep Dive: Data Storage and Retrieval
JAM819 - Native API Deep Dive: Data Storage and RetrievalJAM819 - Native API Deep Dive: Data Storage and Retrieval
JAM819 - Native API Deep Dive: Data Storage and Retrieval
 
2310 b 09
2310 b 092310 b 09
2310 b 09
 
Ado dot net complete meterial (1)
Ado dot net complete meterial (1)Ado dot net complete meterial (1)
Ado dot net complete meterial (1)
 
Ado
AdoAdo
Ado
 
Handy annotations-within-oracle-10g
Handy annotations-within-oracle-10gHandy annotations-within-oracle-10g
Handy annotations-within-oracle-10g
 
Intake 38 data access 1
Intake 38 data access 1Intake 38 data access 1
Intake 38 data access 1
 

Similaire à Ado.net session10

Session 9 Tp9
Session 9 Tp9Session 9 Tp9
Session 9 Tp9phanleson
 
J2ee Transaction Overview
J2ee Transaction OverviewJ2ee Transaction Overview
J2ee Transaction OverviewTerry Cho
 
Scaling Cloud-Scale Translytics Workloads with Omid and Phoenix
Scaling Cloud-Scale Translytics Workloads with Omid and PhoenixScaling Cloud-Scale Translytics Workloads with Omid and Phoenix
Scaling Cloud-Scale Translytics Workloads with Omid and PhoenixDataWorks Summit
 
Whats new in .net framework 4
Whats new in .net framework 4Whats new in .net framework 4
Whats new in .net framework 4Pramod Chavan
 
DDD Framework for Java: JdonFramework
DDD Framework for Java: JdonFrameworkDDD Framework for Java: JdonFramework
DDD Framework for Java: JdonFrameworkbanq jdon
 
The .net remote systems
The .net remote systemsThe .net remote systems
The .net remote systemsRaghu nath
 
Introduction To Dot Net Siddhesh
Introduction To Dot Net SiddheshIntroduction To Dot Net Siddhesh
Introduction To Dot Net SiddheshSiddhesh Bhobe
 
DBF-Lecture11-Chapter12.pptDatabase Principles Fundam.docx
DBF-Lecture11-Chapter12.pptDatabase Principles Fundam.docxDBF-Lecture11-Chapter12.pptDatabase Principles Fundam.docx
DBF-Lecture11-Chapter12.pptDatabase Principles Fundam.docxrandyburney60861
 
MicroServices at Netflix - challenges of scale
MicroServices at Netflix - challenges of scaleMicroServices at Netflix - challenges of scale
MicroServices at Netflix - challenges of scaleSudhir Tonse
 
Transaction and concurrency pitfalls in Java
Transaction and concurrency pitfalls in JavaTransaction and concurrency pitfalls in Java
Transaction and concurrency pitfalls in JavaErsen Öztoprak
 
Dot net training-navimumbai
Dot net training-navimumbaiDot net training-navimumbai
Dot net training-navimumbaivibrantuser
 
Topic2 Understanding Middleware
Topic2 Understanding MiddlewareTopic2 Understanding Middleware
Topic2 Understanding Middlewaresanjoysanyal
 

Similaire à Ado.net session10 (20)

Session 9 Tp9
Session 9 Tp9Session 9 Tp9
Session 9 Tp9
 
J2ee Transaction Overview
J2ee Transaction OverviewJ2ee Transaction Overview
J2ee Transaction Overview
 
Scaling Cloud-Scale Translytics Workloads with Omid and Phoenix
Scaling Cloud-Scale Translytics Workloads with Omid and PhoenixScaling Cloud-Scale Translytics Workloads with Omid and Phoenix
Scaling Cloud-Scale Translytics Workloads with Omid and Phoenix
 
Whats new in .net framework 4
Whats new in .net framework 4Whats new in .net framework 4
Whats new in .net framework 4
 
DDD Framework for Java: JdonFramework
DDD Framework for Java: JdonFrameworkDDD Framework for Java: JdonFramework
DDD Framework for Java: JdonFramework
 
Introduction to Visual Studio.NET
Introduction to Visual Studio.NETIntroduction to Visual Studio.NET
Introduction to Visual Studio.NET
 
The .net remote systems
The .net remote systemsThe .net remote systems
The .net remote systems
 
Introduction To Dot Net Siddhesh
Introduction To Dot Net SiddheshIntroduction To Dot Net Siddhesh
Introduction To Dot Net Siddhesh
 
CH09.ppt
CH09.pptCH09.ppt
CH09.ppt
 
DBF-Lecture11-Chapter12.pptDatabase Principles Fundam.docx
DBF-Lecture11-Chapter12.pptDatabase Principles Fundam.docxDBF-Lecture11-Chapter12.pptDatabase Principles Fundam.docx
DBF-Lecture11-Chapter12.pptDatabase Principles Fundam.docx
 
Dot net Introduction and their usabilities
Dot net Introduction and  their usabilitiesDot net Introduction and  their usabilities
Dot net Introduction and their usabilities
 
MicroServices at Netflix - challenges of scale
MicroServices at Netflix - challenges of scaleMicroServices at Netflix - challenges of scale
MicroServices at Netflix - challenges of scale
 
5c8605.ado.net
5c8605.ado.net5c8605.ado.net
5c8605.ado.net
 
dot NET Framework
dot NET Frameworkdot NET Framework
dot NET Framework
 
Nodejs Session01
Nodejs Session01Nodejs Session01
Nodejs Session01
 
Tibco iprocess suite
Tibco iprocess suiteTibco iprocess suite
Tibco iprocess suite
 
Transaction and concurrency pitfalls in Java
Transaction and concurrency pitfalls in JavaTransaction and concurrency pitfalls in Java
Transaction and concurrency pitfalls in Java
 
VB Dot net
VB Dot net VB Dot net
VB Dot net
 
Dot net training-navimumbai
Dot net training-navimumbaiDot net training-navimumbai
Dot net training-navimumbai
 
Topic2 Understanding Middleware
Topic2 Understanding MiddlewareTopic2 Understanding Middleware
Topic2 Understanding Middleware
 

Plus de Niit Care (20)

Ajs 1 b
Ajs 1 bAjs 1 b
Ajs 1 b
 
Ajs 4 b
Ajs 4 bAjs 4 b
Ajs 4 b
 
Ajs 4 a
Ajs 4 aAjs 4 a
Ajs 4 a
 
Ajs 4 c
Ajs 4 cAjs 4 c
Ajs 4 c
 
Ajs 3 b
Ajs 3 bAjs 3 b
Ajs 3 b
 
Ajs 3 a
Ajs 3 aAjs 3 a
Ajs 3 a
 
Ajs 3 c
Ajs 3 cAjs 3 c
Ajs 3 c
 
Ajs 2 b
Ajs 2 bAjs 2 b
Ajs 2 b
 
Ajs 2 a
Ajs 2 aAjs 2 a
Ajs 2 a
 
Ajs 2 c
Ajs 2 cAjs 2 c
Ajs 2 c
 
Ajs 1 a
Ajs 1 aAjs 1 a
Ajs 1 a
 
Ajs 1 c
Ajs 1 cAjs 1 c
Ajs 1 c
 
Dacj 4 2-c
Dacj 4 2-cDacj 4 2-c
Dacj 4 2-c
 
Dacj 4 2-b
Dacj 4 2-bDacj 4 2-b
Dacj 4 2-b
 
Dacj 4 2-a
Dacj 4 2-aDacj 4 2-a
Dacj 4 2-a
 
Dacj 4 1-c
Dacj 4 1-cDacj 4 1-c
Dacj 4 1-c
 
Dacj 4 1-b
Dacj 4 1-bDacj 4 1-b
Dacj 4 1-b
 
Dacj 4 1-a
Dacj 4 1-aDacj 4 1-a
Dacj 4 1-a
 
Dacj 1-2 b
Dacj 1-2 bDacj 1-2 b
Dacj 1-2 b
 
Dacj 1-3 c
Dacj 1-3 cDacj 1-3 c
Dacj 1-3 c
 

Dernier

Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesDavid Newbury
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6DianaGray10
 
VoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXVoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXTarek Kalaji
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintMahmoud Rabie
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URLRuncy Oommen
 
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding TeamAdam Moalla
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsSeth Reyes
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfJamie (Taka) Wang
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfDianaGray10
 
COMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a WebsiteCOMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a Websitedgelyza
 
Machine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfMachine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfAijun Zhang
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesMd Hossain Ali
 
Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Brian Pichman
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...DianaGray10
 
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsIgniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsSafe Software
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAshyamraj55
 
AI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarAI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarPrecisely
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfinfogdgmi
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Commit University
 

Dernier (20)

Linked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond OntologiesLinked Data in Production: Moving Beyond Ontologies
Linked Data in Production: Moving Beyond Ontologies
 
UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6UiPath Studio Web workshop series - Day 6
UiPath Studio Web workshop series - Day 6
 
VoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBXVoIP Service and Marketing using Odoo and Asterisk PBX
VoIP Service and Marketing using Odoo and Asterisk PBX
 
Empowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership BlueprintEmpowering Africa's Next Generation: The AI Leadership Blueprint
Empowering Africa's Next Generation: The AI Leadership Blueprint
 
Designing A Time bound resource download URL
Designing A Time bound resource download URLDesigning A Time bound resource download URL
Designing A Time bound resource download URL
 
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and Hazards
 
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
activity_diagram_combine_v4_20190827.pdfactivity_diagram_combine_v4_20190827.pdf
 
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdfUiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
UiPath Solutions Management Preview - Northern CA Chapter - March 22.pdf
 
COMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a WebsiteCOMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a Website
 
Machine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfMachine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdf
 
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just MinutesAI Fame Rush Review – Virtual Influencer Creation In Just Minutes
AI Fame Rush Review – Virtual Influencer Creation In Just Minutes
 
Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )Building Your Own AI Instance (TBLC AI )
Building Your Own AI Instance (TBLC AI )
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
 
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration WorkflowsIgniting Next Level Productivity with AI-Infused Data Integration Workflows
Igniting Next Level Productivity with AI-Infused Data Integration Workflows
 
20230104 - machine vision
20230104 - machine vision20230104 - machine vision
20230104 - machine vision
 
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPAAnypoint Code Builder , Google Pub sub connector and MuleSoft RPA
Anypoint Code Builder , Google Pub sub connector and MuleSoft RPA
 
AI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity WebinarAI You Can Trust - Ensuring Success with Data Integrity Webinar
AI You Can Trust - Ensuring Success with Data Integrity Webinar
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdf
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)
 

Ado.net session10

  • 1. Developing Database Applications Using ADO.NET and XML Objectives In this session, you will learn to: Manage local transactions Manage distributed transactions Ver. 1.0 Session 10 Slide 1 of 31
  • 2. Developing Database Applications Using ADO.NET and XML Managing Local Transactions A transaction can be defined as a sequence of operations that are performed together as a single logical unit of work. If a transaction is successful, all the data modifications performed in the database will be committed and saved. If a transaction fails or an error occurs, then the transaction is rolled back to undo the data modifications done in the database. Ver. 1.0 Session 10 Slide 2 of 31
  • 3. Developing Database Applications Using ADO.NET and XML Properties of a Transaction For a transaction to commit successfully within a database, it should possess the following four properties:  Atomicity States that either all the modifications are performed or none of them are performed  Consistency States that data is in a consistent state after a transaction is completed successfully to maintain the integrity of data  Isolation States that any data modification made by one transaction must be isolated from the modifications made by the other transaction  Durability States that any change in data by a completed transaction remains permanently in effect in the database Ver. 1.0 Session 10 Slide 3 of 31
  • 4. Developing Database Applications Using ADO.NET and XML Types of Transaction ADO.NET provides support for two types of transactions: Local transactions A local transaction performs on a single data source. Because local transactions are performed on a single data source, these transactions are efficient to operate and easy to manage. A distributed transaction performs on Distributed transactions multiple data sources. Distributed transactions enable you to incorporate several distinct transactional operations into an atomic unit that either succeed or fail completely. Ver. 1.0 Session 10 Slide 4 of 31
  • 5. Developing Database Applications Using ADO.NET and XML Performing Local Transactions • ADO.NET has an interface, IDbTransaction that contains methods for creating and performing local transactions against a single data source. • The following table lists the transaction classes available in the .NET Framework 2.0. Types of Transaction Classes Description System.Data.SqlClient.SqlTransaction Transaction class for .NET framework data provider for SQL Server System.Data.OleDb.OleDbTransaction Transaction class for .NET framework data provider for OLE DB System.Data.Odbc.OdbcTransaction Transaction class for .NET framework data provider for ODBC System.Data.OracleClient.OracleTransaction Transaction class for .NET framework data provider for Oracle Ver. 1.0 Session 10 Slide 5 of 31
  • 6. Developing Database Applications Using ADO.NET and XML Performing Local Transactions (Contd.) Let us understand how to create a local transaction. string connectString = Creating a connection to the data source "Initial Catalog=AdventureWorks; Data Source=SQLSERVER01; User id=sa;Password=niit#1234"; SqlConnection cn = new SqlConnection(); cn.Open(); cn = connectString; SqlTransaction tran = null; Ver. 1.0 Session 10 Slide 6 of 31
  • 7. Developing Database Applications Using ADO.NET and XML Performing Local Transactions (Contd.) try { tran = cn.BeginTransaction(); Calling the BeginTransaction() SqlCommand cmd = new method Creating the command object and SqlCommand("INSERT INTO passing the SQL command empdetails(ccode,cname, caddress,cstate,ccountry, cDesignation,cDepartment) VALUES(1101,'Linda Taylor', 'Oxfordshire','London', 'UK','Manager','Finance')", cn, tran); Ver. 1.0 Session 10 Slide 7 of 31
  • 8. Developing Database Applications Using ADO.NET and XML Performing Local Transactions (Contd.) cmd.ExecuteNonQuery(); Committing the transaction if the command succeeds tran.Commit(); Console.WriteLine("Transaction Committedn)"; } catch (SqlException ex) { Rolling back the transaction if the tran.Rollback(); command fails Console.WriteLine("Error - TRANSACTION ROLLED BACKn" + ex.Message); } Ver. 1.0 Session 10 Slide 8 of 31
  • 9. Developing Database Applications Using ADO.NET and XML Performing Local Transactions (Contd.) catch (System.Exception ex) { Console.WriteLine("System Errorn" + ex.Message); } finally { cn.Close(); } Console.ReadLine(); } } } Ver. 1.0 Session 10 Slide 9 of 31
  • 10. Developing Database Applications Using ADO.NET and XML Just a minute Which method is called when a transaction succeeds in its operation? 1. Rollback() 2. Commit() 3. BeginTransaction() 4. ExecuteNonQuery() Answer: 2. Commit() Ver. 1.0 Session 10 Slide 10 of 31
  • 11. Developing Database Applications Using ADO.NET and XML Demo: Managing Local Transactions Problem Statement: John Howard, the HR executive has joined as a head of the Finance department at Texas. Therefore, his details need to be added to the HR database. The Department code for the Finance department is D002. The user name that needs to be assigned to him is JohnH and the password is howard. As a part of the development team, you need to create a transaction that will allow you to add these details in the HRusers and Department tables. Ver. 1.0 Session 10 Slide 11 of 31
  • 12. Developing Database Applications Using ADO.NET and XML Managing Distributed Transactions • Distributed transactions are performed on multiple data sources or multiple connections within a data source. • Distributed transactions are created in the System.Transaction namespace. • The System.Transaction namespace has a TransactionScope class, which enables a developer to create and manage distributed transactions. • To create a distributed transaction, a TransactionScope object is created in a using block. • The TransactionScope object decides whether to create a local transaction or a distributed transaction. This is known as transaction promotion. Ver. 1.0 Session 10 Slide 12 of 31
  • 13. Developing Database Applications Using ADO.NET and XML Managing Distributed Transactions (Contd.) Let us understand how to create a distributed transaction. using (TransactionScope ts Creating the TransactionScope = new TransactionScope()) object { using(SqlConnection cn Creating a connection to the data = new SqlConnection("Initial source Catalog=HR;Data Source=SQLSERVER01;User id=sa;Password=niit#1234")) { cn.Open(); Ver. 1.0 Session 10 Slide 13 of 31
  • 14. Developing Database Applications Using ADO.NET and XML Managing Distributed Transactions (Contd.) using(SqlCommand cmd = new Creating a SqlCommand object to insert a record in the SqlCommand("INSERT INTO HRusers table HRusers(cUserName,cPassword) VALUES('Darren','Cooper')", cn)) { int rowsUpdated = cmd.ExecuteNonQuery(); if (rowsUpdated > 0) { Ver. 1.0 Session 10 Slide 14 of 31
  • 15. Developing Database Applications Using ADO.NET and XML Managing Distributed Transactions (Contd.) SqlConnection cn1 = new Creating another connection to the SqlConnection("Initial same data source Catalog=HR;Data Source=SQLSERVER01;User id=sa;Password=niit#1234")) { cn1.Open(); using (SqlCommand cmd1 = Creating another SqlCommand object to delete a record in the new SqlCommand("DELETE Department table Department WHERE cDepartmentCode=1111", cn1)) { int rowsUpdated1 = cmd1.ExecuteNonQuery(); Ver. 1.0 Session 10 Slide 15 of 31
  • 16. Developing Database Applications Using ADO.NET and XML Managing Distributed Transactions (Contd.) if (rowsUpdated1 > 0) { ts.Complete(); Calling the Complete() method to commit the transactions Console.WriteLine ("Transaction Committedn"); cn1.Close(); } }}} cn.Close(); }} Console.ReadLine(); }}} Ver. 1.0 Session 10 Slide 16 of 31
  • 17. Developing Database Applications Using ADO.NET and XML Just a minute The _______ method is invoked to commit the distributed transaction. 1. Commit() 2. BeginTransaction() 3. Complete() 4. Rollback() Answer: 3. Complete() Ver. 1.0 Session 10 Slide 17 of 31
  • 18. Developing Database Applications Using ADO.NET and XML Performing Bulk Copy Operations in a Transaction • Bulk copy operations can be performed as an isolated operation or as a part of a transaction. • By default, a bulk copy operation is its own transaction. • To perform a bulk copy operation, you need to create a new instance of BulkCopy class with a connection string. • The bulk copy operation creates, and then, commits or rolls back the transaction. Ver. 1.0 Session 10 Slide 18 of 31
  • 19. Developing Database Applications Using ADO.NET and XML Specifying Isolation Levels of a Transaction An isolation level determines the effect a transaction has on other transactions that are currently running, and vice versa. By default, all transactions are completely isolated and run concurrently without impacting each other. The isolation level of a transaction specifies the locking strategy used by the connection running the transaction to prevent concurrency problems when multiple transactions access the same data. Ver. 1.0 Session 10 Slide 19 of 31
  • 20. Developing Database Applications Using ADO.NET and XML Specifying Isolation Levels of a Transaction (Contd.) The following table describes the concurrency errors that can occur if multiple transactions access the same data at the same time. Concurrency Error Description Dirty read A transaction reads the data that has not been committed by the other transaction. This can create problem if a transaction that has added the data is rolled back. Nonrepeatable read A transaction reads the same row more than once and a different transaction modifies the row between the reads. Phantom read A transaction reads a rowset more than once and a different transaction inserts or deletes rows between the first transaction’s reads. Ver. 1.0 Session 10 Slide 20 of 31
  • 21. Developing Database Applications Using ADO.NET and XML Specifying Isolation Levels of a Transaction (Contd.) The various types of isolation levels of a transaction are:  Read Uncommitted  Read Committed with Locks  Read Committed with Snapshots  Repeatable Read  Snapshot  Serializable Ver. 1.0 Session 10 Slide 21 of 31
  • 22. Developing Database Applications Using ADO.NET and XML Specifying Isolation Levels of a Transaction (Contd.) The following table describes the various isolation levels and the corresponding concurrency errors for a transaction. Isolation Level Dirty Read Nonrepeatable Read Phantom Read Read Uncommitted Yes Yes Yes Read Committed No Yes Yes with Locks Read Committed No Yes Yes with Snapshots Repeatable Read No No Yes Snapshot No No No Serializable No No No Ver. 1.0 Session 10 Slide 22 of 31
  • 23. Developing Database Applications Using ADO.NET and XML Specifying Isolation Levels of a Transaction (Contd.) Let us understand how to set the isolation level of a transaction to Read Committed. TransactionOptions options = new Initializing the TransactionOptions TransactionOptions(); object options.IsolationLevel = Setting the Isolation level of System.Transactions.IsolationLevel. both transactions to Read Committed ReadC ommitted; using(TransactionScope ts = new TransactionScope (TransactionScopeOption. Required, options)){ using (SqlConnection cn = new Creating a connection to a data source SqlConnection("Initial Catalog= HR;Data Source=SQLSERVER01; User id=sa;Password=niit#1234;")){ cn.Open(); Ver. 1.0 Session 10 Slide 23 of 31
  • 24. Developing Database Applications Using ADO.NET and XML Specifying Isolation Levels of a Transaction (Contd.) using(SqlCommand cmd = new Creating a SqlCommand object to insert a record in the SqlCommand("INSERT INTO Department table Department(cDepartmentCode ,vDepartmentName,vDepartmentHead, vLocation) VALUES(2013,'IT','Lara King','Houston')", cn)){ int rowsUpdated = cmd.ExecuteNonQuery(); if (rowsUpdated > 0) { Ver. 1.0 Session 10 Slide 24 of 31
  • 25. Developing Database Applications Using ADO.NET and XML Specifying Isolation Levels of a Transaction (Contd.) using (SqlConnection cn1 = Creating another connection to the same data source new SqlConnection("Initial Catalog=HR;Data Source=SQLSERVER01;User id=sa;Password=niit#1234")) { cn1.Open(); using(SqlCommand cmd = new Creating another command SqlCommand("INSERT INTO object to insert a record in the HRusers table HRusers(cUserName,cPassword ) VALUES('Hansel','Lord')", cn1)) Ver. 1.0 Session 10 Slide 25 of 31
  • 26. Developing Database Applications Using ADO.NET and XML Specifying Isolation Levels of a Transaction (Contd.) { int rowsUpdated1 = cmd1.ExecuteNonQuery(); if (rowsUpdated1 > 0) { ts.Complete(); Calling the Complete() method to commit both transactions }}}} Ver. 1.0 Session 10 Slide 26 of 31
  • 27. Developing Database Applications Using ADO.NET and XML Just a minute Which isolation level supports the occurrence of Dirty read, Nonrepeatable read, and Phantom read? 1. Read Committed with Locks 2. Serializable 3. Read Committed with Snapshots 4. Read Uncommitted Answer: 4. Read Uncommitted Ver. 1.0 Session 10 Slide 27 of 31
  • 28. Developing Database Applications Using ADO.NET and XML Demo: Managing Distributed Transactions Problem Statement: Pamela Cruz has joined as an HR executive in Tebisco. Therefore, her details that includes user name and password needs to be inserted in the HRusers table. In addition, the details about her position needs to be added in the Position table. Both the operations need to be performed simultaneously in both the tables. As a part of the development team, you need to add the required details for Pamela in the HR database. Note: To enable execution of the distributed transactions, you need to ensure that the MSDTC services are running on your system. Ver. 1.0 Session 10 Slide 28 of 31
  • 29. Developing Database Applications Using ADO.NET and XML Summary In this session, you learned that: A transaction is a logical unit of work that must be completed to maintain the consistency and integrity of a database. A transaction has the following properties:  Atomicity  Consistency  Isolation  Durability The two types of transaction are: Local transactions Distributed transactions Ver. 1.0 Session 10 Slide 29 of 31
  • 30. Developing Database Applications Using ADO.NET and XML Summary (Contd.)  A local transaction performs on a single data source. The IDbTransaction interface contains methods for creating and performing local transactions against a data source.  A distributed transaction performs on multiple data sources. A distributed transaction enables you to incorporate several distinct transactional operations into an atomic unit that either succeed or fail completely.  Bulk copy operations can be performed as an isolated operations or as a part of a transaction. By default, a bulk copy operation is its own transaction.  An isolation level determines the effect a transaction has on other transactions that are currently running, and vice versa. Ver. 1.0 Session 10 Slide 30 of 31
  • 31. Developing Database Applications Using ADO.NET and XML Summary (Contd.) The various concurrency errors that can occur when multiple transactions access the same data at the same time are:  Dirty read  Nonrepeatable read  Phantom read The various types of isolation levels are for a transaction are: Read Uncommitted Read Committed with Locks Read Committed with Snapshots Repeatable Read Snapshot Serializable Ver. 1.0 Session 10 Slide 31 of 31

Notes de l'éditeur

  1. Introduce the students to the course by asking them what they know about forensics. Next, ask the students what they know about system forensics and why is it required in organizations dependent on IT. This could be a brief discussion of about 5 minutes. Lead the discussion to the objectives of this chapter.
  2. Introduce the students to the different types of threats that systems face by: Asking the students to give examples of what they think are environmental and human threats. Asking the students to give instances of what they think are malicious and non-malicious threats. Conclude the discussion on the different types of threats by giving additional examples of malicious and non malicious threats.
  3. Introduce the students to the different types of threats that systems face by: Asking the students to give examples of what they think are environmental and human threats. Asking the students to give instances of what they think are malicious and non-malicious threats. Conclude the discussion on the different types of threats by giving additional examples of malicious and non malicious threats.
  4. Introduce the students to the different types of threats that systems face by: Asking the students to give examples of what they think are environmental and human threats. Asking the students to give instances of what they think are malicious and non-malicious threats. Conclude the discussion on the different types of threats by giving additional examples of malicious and non malicious threats.
  5. Introduce the students to the different types of threats that systems face by: Asking the students to give examples of what they think are environmental and human threats. Asking the students to give instances of what they think are malicious and non-malicious threats. Conclude the discussion on the different types of threats by giving additional examples of malicious and non malicious threats.
  6. Introduce the students to the different types of threats that systems face by: Asking the students to give examples of what they think are environmental and human threats. Asking the students to give instances of what they think are malicious and non-malicious threats. Conclude the discussion on the different types of threats by giving additional examples of malicious and non malicious threats.
  7. Introduce the students to the different types of threats that systems face by: Asking the students to give examples of what they think are environmental and human threats. Asking the students to give instances of what they think are malicious and non-malicious threats. Conclude the discussion on the different types of threats by giving additional examples of malicious and non malicious threats.
  8. Introduce the students to the different types of threats that systems face by: Asking the students to give examples of what they think are environmental and human threats. Asking the students to give instances of what they think are malicious and non-malicious threats. Conclude the discussion on the different types of threats by giving additional examples of malicious and non malicious threats.
  9. Introduce the students to the different types of threats that systems face by: Asking the students to give examples of what they think are environmental and human threats. Asking the students to give instances of what they think are malicious and non-malicious threats. Conclude the discussion on the different types of threats by giving additional examples of malicious and non malicious threats.
  10. In this slide you need to show the calculation to determine the sum of an arithmetic progression for bubble sort algorithm. Refer to student guide.
  11. While explaining the definition of system forensics, ask the students to note the following key words in the definition: Identify Extract Process Analyze Digital and hardware evidence Tell the students that these form an integral aspect of system forensics and would be discussed in detail. Before moving on to the next slide, hold a brief discussion on why is it important for organizations to take the help of system forensics. The discussion should be focused on: The role that system forensics plays in organizations having an IT set up. This discussion will serve as a precursor to the next slide.
  12. While explaining the definition of system forensics, ask the students to note the following key words in the definition: Identify Extract Process Analyze Digital and hardware evidence Tell the students that these form an integral aspect of system forensics and would be discussed in detail. Before moving on to the next slide, hold a brief discussion on why is it important for organizations to take the help of system forensics. The discussion should be focused on: The role that system forensics plays in organizations having an IT set up. This discussion will serve as a precursor to the next slide.
  13. Introduce the students to the different types of threats that systems face by: Asking the students to give examples of what they think are environmental and human threats. Asking the students to give instances of what they think are malicious and non-malicious threats. Conclude the discussion on the different types of threats by giving additional examples of malicious and non malicious threats.
  14. Introduce the students to the different types of threats that systems face by: Asking the students to give examples of what they think are environmental and human threats. Asking the students to give instances of what they think are malicious and non-malicious threats. Conclude the discussion on the different types of threats by giving additional examples of malicious and non malicious threats.
  15. Introduce the students to the different types of threats that systems face by: Asking the students to give examples of what they think are environmental and human threats. Asking the students to give instances of what they think are malicious and non-malicious threats. Conclude the discussion on the different types of threats by giving additional examples of malicious and non malicious threats.
  16. Introduce the students to the different types of threats that systems face by: Asking the students to give examples of what they think are environmental and human threats. Asking the students to give instances of what they think are malicious and non-malicious threats. Conclude the discussion on the different types of threats by giving additional examples of malicious and non malicious threats.
  17. In this slide you need to show the calculation to determine the sum of an arithmetic progression for bubble sort algorithm. Refer to student guide.
  18. While explaining the definition of system forensics, ask the students to note the following key words in the definition: Identify Extract Process Analyze Digital and hardware evidence Tell the students that these form an integral aspect of system forensics and would be discussed in detail. Before moving on to the next slide, hold a brief discussion on why is it important for organizations to take the help of system forensics. The discussion should be focused on: The role that system forensics plays in organizations having an IT set up. This discussion will serve as a precursor to the next slide.
  19. While explaining the definition of system forensics, ask the students to note the following key words in the definition: Identify Extract Process Analyze Digital and hardware evidence Tell the students that these form an integral aspect of system forensics and would be discussed in detail. Before moving on to the next slide, hold a brief discussion on why is it important for organizations to take the help of system forensics. The discussion should be focused on: The role that system forensics plays in organizations having an IT set up. This discussion will serve as a precursor to the next slide.
  20. While explaining the definition of system forensics, ask the students to note the following key words in the definition: Identify Extract Process Analyze Digital and hardware evidence Tell the students that these form an integral aspect of system forensics and would be discussed in detail. Before moving on to the next slide, hold a brief discussion on why is it important for organizations to take the help of system forensics. The discussion should be focused on: The role that system forensics plays in organizations having an IT set up. This discussion will serve as a precursor to the next slide.
  21. While explaining the definition of system forensics, ask the students to note the following key words in the definition: Identify Extract Process Analyze Digital and hardware evidence Tell the students that these form an integral aspect of system forensics and would be discussed in detail. Before moving on to the next slide, hold a brief discussion on why is it important for organizations to take the help of system forensics. The discussion should be focused on: The role that system forensics plays in organizations having an IT set up. This discussion will serve as a precursor to the next slide.
  22. While explaining the definition of system forensics, ask the students to note the following key words in the definition: Identify Extract Process Analyze Digital and hardware evidence Tell the students that these form an integral aspect of system forensics and would be discussed in detail. Before moving on to the next slide, hold a brief discussion on why is it important for organizations to take the help of system forensics. The discussion should be focused on: The role that system forensics plays in organizations having an IT set up. This discussion will serve as a precursor to the next slide.
  23. Introduce the students to the different types of threats that systems face by: Asking the students to give examples of what they think are environmental and human threats. Asking the students to give instances of what they think are malicious and non-malicious threats. Conclude the discussion on the different types of threats by giving additional examples of malicious and non malicious threats.
  24. Introduce the students to the different types of threats that systems face by: Asking the students to give examples of what they think are environmental and human threats. Asking the students to give instances of what they think are malicious and non-malicious threats. Conclude the discussion on the different types of threats by giving additional examples of malicious and non malicious threats.
  25. Introduce the students to the different types of threats that systems face by: Asking the students to give examples of what they think are environmental and human threats. Asking the students to give instances of what they think are malicious and non-malicious threats. Conclude the discussion on the different types of threats by giving additional examples of malicious and non malicious threats.
  26. Introduce the students to the different types of threats that systems face by: Asking the students to give examples of what they think are environmental and human threats. Asking the students to give instances of what they think are malicious and non-malicious threats. Conclude the discussion on the different types of threats by giving additional examples of malicious and non malicious threats.
  27. In this slide you need to show the calculation to determine the sum of an arithmetic progression for bubble sort algorithm. Refer to student guide.
  28. While explaining the definition of system forensics, ask the students to note the following key words in the definition: Identify Extract Process Analyze Digital and hardware evidence Tell the students that these form an integral aspect of system forensics and would be discussed in detail. Before moving on to the next slide, hold a brief discussion on why is it important for organizations to take the help of system forensics. The discussion should be focused on: The role that system forensics plays in organizations having an IT set up. This discussion will serve as a precursor to the next slide.