SlideShare uma empresa Scribd logo
1 de 25
Performing Data Updates

Objectives
In this lesson, you will learn to:
Perform cached data updates
Perform direct data updates
Identify the need for concurrency management
Identify the methods of maintaining concurrency in datasets




   ©NIIT                       Performing Data Updates/Lesson 7/Slide 1 of 25
Performing Data Updates

Problem Statement 7.D.1
The Diaz Telecommunications Sales Manager needs to view
the customer details in a customized format. In addition, the
customer details need to be maintained, which involves
adding new customer details, and modifying and deleting the
existing ones.




   ©NIIT                    Performing Data Updates/Lesson 7/Slide 2 of 25
Performing Data Updates

Task List
Identify the data that needs to be maintained.
Identify the mechanism to maintain data.
Design a Windows Form to maintain the data.
Connect to the database.
Bind the data to the Windows Form controls.
Write the code to maintain the data.
Perform data maintenance.




   ©NIIT                    Performing Data Updates/Lesson 7/Slide 3 of 25
Performing Data Updates

Task 1: Identify the data that needs to be maintained.

Result:
As per the given problem statement, the data to be
maintained is as follows:
     CustID
     FName
     LName
     Address
     Phone
     email

   ©NIIT                   Performing Data Updates/Lesson 7/Slide 4 of 25
Performing Data Updates

Task 2: Identify the mechanism to maintain data.
Data can be retrieved from a database directly through
data commands or cached in datasets.
Performing cached data updates
    Updating the dataset
           ® While   updating the dataset, some events are raised:
              ® ColumnChanging

              ® RowChanging

              ® ColumnChanged

              ® RowChanged

              ® RowDeleting

              ® RowDeleted
   ©NIIT                         Performing Data Updates/Lesson 7/Slide 5 of 25
Performing Data Updates

Task 2: Identify the mechanism to maintain data.
(Contd.)
          ® Whileupdating the dataset, the following information
           is maintained:
             ® RowState     property
                ®   Unchanged
                ®   Added
                ®   Deleted
                ®   Detached
                ®   Modified



  ©NIIT                         Performing Data Updates/Lesson 7/Slide 6 of 25
Performing Data Updates

Task 2: Identify the mechanism to maintain data.
(Contd.)
            ® DataRowVersion        Enumeration
                  ®   Original
                  ®   Current
                  ®   Proposed
                  ®   Default
          ® The changes are committed to the dataset by calling
           the AcceptChanges()method.
    Updating the data source
          ® Thedata source is updated with the changed
           dataset by calling the Update()method of the data
           adapter.
  ©NIIT                          Performing Data Updates/Lesson 7/Slide 7 of 25
Performing Data Updates

Just a Minute…
2. When does the RowState property have the value
   Detached?
3. What is the relationship between the RowState property
   and the DataRowVersion enumeration?




   ©NIIT                   Performing Data Updates/Lesson 7/Slide 8 of 25
Performing Data Updates

Task 2: Identify the mechanism to maintain data.
(Contd.)
Performing direct data updates
    Data commands are can be used to directly update the
     data source.
    A data command object can be derived from the
     OleDbCommand class or the SqlCommand class.
    For executing a data command, the Connection,
     CommandText, and the Parameters properties for the
     data command have to be set.




  ©NIIT                   Performing Data Updates/Lesson 7/Slide 9 of 25
Performing Data Updates

Task 2: Identify the mechanism to maintain data.
(Contd.)
Result:
Since you need to access the data through a dataset, you
      will perform a cached data update.




   ©NIIT                  Performing Data Updates/Lesson 7/Slide 10 of 25
Performing Data Updates

Just a Minute…
1. In which cases, direct data update is preferred to updates
   through datasets?
2. Write a code to connect to a database through data
   commands.




   ©NIIT                    Performing Data Updates/Lesson 7/Slide 11 of 25
Performing Data Updates

Task 3: Design a Windows Form to maintain the data.


Task 4: Connect to the database.
Task 5: Bind the data to the Windows Form controls.
Task 6: Write the code to maintain the data.
Task 7: Perform data maintenance.




  ©NIIT                Performing Data Updates/Lesson 7/Slide 12 of 25
Performing Data Updates

Maintaining Data Concurrency
Concurrency control is the process of ensuring that in case
     many people attempt to modify data in a database at
the  same time, modifications made by one person do not
     adversely affect those of another person.

                  Method                                Description


   Pessimistic concurrency control    In this type of concurrency control, a system of
                                      locks applied does not allow users to modify data
                                      in a way that affects other users. When a lock is
                                      applied, other users cannot perform actions that
                                      would conflict with the lock until the owner
                                      releases it. Pessimistic control is mainly used in
                                      environments where the data contention is high
                                      and protecting data with locks is less costly than
                                      rolling back transactions in case of concurrency
                                      conflicts. Pessimistic concurrency is not possible
                                      in a disconnected architecture.




   ©NIIT                             Performing Data Updates/Lesson 7/Slide 13 of 25
Performing Data Updates

Maintaining Data Concurrency (Contd.)

                   Method                                    Description


   Optimistic concurrency control         In this type of concurrency control, the lock is not
                                          applied when the users read the data. When the
                                          user performs a data update, the system checks to
                                          see if the data has been changed by another user
                                          after the data was read. If the data has been
                                          changed, an error is raised. Optimistic concurrency
                                          is used in environments where the data contention
                                          is low and protecting data with locks is more costly
                                          than rolling back transaction in case of concurrency
                                          conflicts.



   ‘Last in Wins’ concurrency control     This type of concurrency control works in a similar
                                          way as the optimistic concurrency control, with the
                                          difference that the record is updated regardless of
                                          whether the record has been changed or not.




  ©NIIT                                 Performing Data Updates/Lesson 7/Slide 14 of 25
Performing Data Updates

Maintaining Data Concurrency (Contd.)
ADO.NET implements optimistic concurrency by using the
     following two methods:
    The Version number method
          ® Theversion number method requires the record to
           be updated to have a datetime stamp or a version
           number column.
    The saving all values method
          ® When   the data is retrieved, a copy of all fields, that
           is, the original version is maintained on the client.




  ©NIIT                        Performing Data Updates/Lesson 7/Slide 15 of 25
Performing Data Updates

Just a Minute…
What is the difference between the concurrency control
through the Saving All method and the Version Number
method?




   ©NIIT                  Performing Data Updates/Lesson 7/Slide 16 of 25
Performing Data Updates

Optimistic Concurrency through Data Adapter
By default, the data adapters that are created in an
application implement optimistic concurrency.




   ©NIIT                   Performing Data Updates/Lesson 7/Slide 17 of 25
Performing Data Updates

Problem Statement 7.P.1
The Sales Manager of Diaz Telecommunications needs to
maintain customer details, which involves adding new
customer details, and modifying and deleting existing
customer details. While adding and modifying details, the
application should ensure that no field is left blank.




   ©NIIT                   Performing Data Updates/Lesson 7/Slide 18 of 25
Performing Data Updates

Summary
In this lesson, you learned that:
Data can be retrieved from a database directly through data
      commands or can be cached in datasets.
When a dataset is used to access data, updating the
database consists of two steps, updating the dataset and
updating the database.
When you make changes to a record in the table, the
following events are raised by the DataTable object:
     ColumnChanging
     RowChanging
     ColumnChanged
   ©NIIT                     Performing Data Updates/Lesson 7/Slide 19 of 25
Performing Data Updates

Summary (Contd.)
    RowChanged
    RowDeleting
    RowDeleted
The ColumnChanging and RowChanging events raised by
       the DataTable object are used to validate the dataset
 while        updating it.
When changes are made in a dataset, that is, a row is
 added, deleted, or modified, some information about each
     update has to be maintained.




   ©NIIT                   Performing Data Updates/Lesson 7/Slide 20 of 25
Performing Data Updates

Summary (Contd.)
 The data adapter uses the following information while
  updating the data source:
    The RowState property — The RowState property of the
     DataRow object indicates the current state of the
     record.
    The DataRowVersion enumeration — A dataset can
     maintain four versions of a DataRow object: Current,
     Original, Proposed, and Default.
 After the changes have been made, they are committed to
  the dataset by calling the AcceptChanges() method of the
  dataset to accept the changes made to the dataset.


   ©NIIT                   Performing Data Updates/Lesson 7/Slide 21 of 25
Performing Data Updates

Summary (Contd.)
The data source is updated with the changed dataset by
calling the Update() method of the OleDbDataAdapter class.
Data commands are generally used in the following cases:
    To work with stored procedures that return a result set,
     which can be manipulated
    To access data that is not appropriate for storing in a
     dataset, such as data with a short life cycle
    To access read-only data, that is, data that will not be
     updated
 A data command object can be derived from the
OleDbCommand class or the SqlCommand class.

   ©NIIT                   Performing Data Updates/Lesson 7/Slide 22 of 25
Performing Data Updates

Summary (Contd.)
A data command object can be derived from the
OleDbCommand class or the SqlCommand class.
For executing a data command, the Connection and
      the CommandText properties for the command
have to       be set for specifying the connection and the
SQL query to be executed to retrieve the data,
respectively.
‘Concurrency’ means ‘at the same time’; thus,
concurrency management means to decide the action
      that will take place when multiple users try to
update        the same record.

  ©NIIT                  Performing Data Updates/Lesson 7/Slide 23 of 25
Performing Data Updates

Summary (Contd.)
 There are three concurrency management methods
  available:
    Pessimistic concurrency control — In this type of
     concurrency control, a record is not available to other
     users from the time that a user begins to edit the record
     till the time that the record is updated in the database.
    Optimistic concurrency control — In this type of
     concurrency control, the record is not available to other
     users only when the record is being updated in the
     database. When a user tries to update a record that has
     been changed, an error occurs.



  ©NIIT                    Performing Data Updates/Lesson 7/Slide 24 of 25
Performing Data Updates

Summary (Contd.)
    Last in Wins concurrency control — This type of
     concurrency control works similar to the optimistic
     concurrency control, the only difference being that the
     record is updated without checking whether the record
     has been changed or not.
 When the row is changed and there is an attempt to
 update the database, ADO.NET uses two methods to
 determine if any changes have occurred:
    The Version number method
    The saving all values method
 By default, the data adapters that are created in an
 application implement optimistic concurrency.
   ©NIIT                   Performing Data Updates/Lesson 7/Slide 25 of 25

Mais conteúdo relacionado

Semelhante a Vb net xp_07

Vb.net session 07
Vb.net session 07Vb.net session 07
Vb.net session 07Niit Care
 
Vb.net session 06
Vb.net session 06Vb.net session 06
Vb.net session 06Niit Care
 
Vb net xp_06
Vb net xp_06Vb net xp_06
Vb net xp_06Niit Care
 
Change data capture the journey to real time bi
Change data capture the journey to real time biChange data capture the journey to real time bi
Change data capture the journey to real time biAsis Mohanty
 
17855584.ppt
17855584.ppt17855584.ppt
17855584.pptNoorEjaz1
 
DDB - integrity Enfrcement
DDB - integrity EnfrcementDDB - integrity Enfrcement
DDB - integrity EnfrcementRashiqa Qureshi
 
Unlocking the Full Power of Your Backup Data with Veritas NetBackup Data Virt...
Unlocking the Full Power of Your Backup Data with Veritas NetBackup Data Virt...Unlocking the Full Power of Your Backup Data with Veritas NetBackup Data Virt...
Unlocking the Full Power of Your Backup Data with Veritas NetBackup Data Virt...Veritas Technologies LLC
 
DIS_Ch12_RinereTamang_revB (1).pptx
DIS_Ch12_RinereTamang_revB (1).pptxDIS_Ch12_RinereTamang_revB (1).pptx
DIS_Ch12_RinereTamang_revB (1).pptxanirudh kasturi
 
Reduce time to complete backups and restores with Transparent Snapshots with ...
Reduce time to complete backups and restores with Transparent Snapshots with ...Reduce time to complete backups and restores with Transparent Snapshots with ...
Reduce time to complete backups and restores with Transparent Snapshots with ...Principled Technologies
 
Vb net xp_05
Vb net xp_05Vb net xp_05
Vb net xp_05Niit Care
 
Oracle data capture c dc
Oracle data capture c dcOracle data capture c dc
Oracle data capture c dcAmit Sharma
 
IRJET- Secure Data Deduplication and Auditing for Cloud Data Storage
IRJET-  	  Secure Data Deduplication and Auditing for Cloud Data StorageIRJET-  	  Secure Data Deduplication and Auditing for Cloud Data Storage
IRJET- Secure Data Deduplication and Auditing for Cloud Data StorageIRJET Journal
 
Distributed Scheme to Authenticate Data Storage Security in Cloud Computing
Distributed Scheme to Authenticate Data Storage Security in Cloud ComputingDistributed Scheme to Authenticate Data Storage Security in Cloud Computing
Distributed Scheme to Authenticate Data Storage Security in Cloud ComputingAIRCC Publishing Corporation
 
DISTRIBUTED SCHEME TO AUTHENTICATE DATA STORAGE SECURITY IN CLOUD COMPUTING
DISTRIBUTED SCHEME TO AUTHENTICATE DATA STORAGE SECURITY IN CLOUD COMPUTINGDISTRIBUTED SCHEME TO AUTHENTICATE DATA STORAGE SECURITY IN CLOUD COMPUTING
DISTRIBUTED SCHEME TO AUTHENTICATE DATA STORAGE SECURITY IN CLOUD COMPUTINGAIRCC Publishing Corporation
 
DISTRIBUTED SCHEME TO AUTHENTICATE DATA STORAGE SECURITY IN CLOUD COMPUTING
DISTRIBUTED SCHEME TO AUTHENTICATE DATA STORAGE SECURITY IN CLOUD COMPUTINGDISTRIBUTED SCHEME TO AUTHENTICATE DATA STORAGE SECURITY IN CLOUD COMPUTING
DISTRIBUTED SCHEME TO AUTHENTICATE DATA STORAGE SECURITY IN CLOUD COMPUTINGijcsit
 
Microsoft Sync Framework (part 1) ABTO Software Lecture Garntsarik
Microsoft Sync Framework (part 1) ABTO Software Lecture GarntsarikMicrosoft Sync Framework (part 1) ABTO Software Lecture Garntsarik
Microsoft Sync Framework (part 1) ABTO Software Lecture GarntsarikABTO Software
 
Distribute Storage System May-2014
Distribute Storage System May-2014Distribute Storage System May-2014
Distribute Storage System May-2014Công Lợi Dương
 

Semelhante a Vb net xp_07 (20)

Vb.net session 07
Vb.net session 07Vb.net session 07
Vb.net session 07
 
Vb.net session 06
Vb.net session 06Vb.net session 06
Vb.net session 06
 
Vb net xp_06
Vb net xp_06Vb net xp_06
Vb net xp_06
 
Change data capture the journey to real time bi
Change data capture the journey to real time biChange data capture the journey to real time bi
Change data capture the journey to real time bi
 
17855584.ppt
17855584.ppt17855584.ppt
17855584.ppt
 
DDB - integrity Enfrcement
DDB - integrity EnfrcementDDB - integrity Enfrcement
DDB - integrity Enfrcement
 
2 countermeasures
2 countermeasures2 countermeasures
2 countermeasures
 
2 countermeasures
2 countermeasures2 countermeasures
2 countermeasures
 
Unlocking the Full Power of Your Backup Data with Veritas NetBackup Data Virt...
Unlocking the Full Power of Your Backup Data with Veritas NetBackup Data Virt...Unlocking the Full Power of Your Backup Data with Veritas NetBackup Data Virt...
Unlocking the Full Power of Your Backup Data with Veritas NetBackup Data Virt...
 
DIS_Ch12_RinereTamang_revB (1).pptx
DIS_Ch12_RinereTamang_revB (1).pptxDIS_Ch12_RinereTamang_revB (1).pptx
DIS_Ch12_RinereTamang_revB (1).pptx
 
Reduce time to complete backups and restores with Transparent Snapshots with ...
Reduce time to complete backups and restores with Transparent Snapshots with ...Reduce time to complete backups and restores with Transparent Snapshots with ...
Reduce time to complete backups and restores with Transparent Snapshots with ...
 
Vb net xp_05
Vb net xp_05Vb net xp_05
Vb net xp_05
 
Oracle data capture c dc
Oracle data capture c dcOracle data capture c dc
Oracle data capture c dc
 
IRJET- Secure Data Deduplication and Auditing for Cloud Data Storage
IRJET-  	  Secure Data Deduplication and Auditing for Cloud Data StorageIRJET-  	  Secure Data Deduplication and Auditing for Cloud Data Storage
IRJET- Secure Data Deduplication and Auditing for Cloud Data Storage
 
INT 1010 07-2.pdf
INT 1010 07-2.pdfINT 1010 07-2.pdf
INT 1010 07-2.pdf
 
Distributed Scheme to Authenticate Data Storage Security in Cloud Computing
Distributed Scheme to Authenticate Data Storage Security in Cloud ComputingDistributed Scheme to Authenticate Data Storage Security in Cloud Computing
Distributed Scheme to Authenticate Data Storage Security in Cloud Computing
 
DISTRIBUTED SCHEME TO AUTHENTICATE DATA STORAGE SECURITY IN CLOUD COMPUTING
DISTRIBUTED SCHEME TO AUTHENTICATE DATA STORAGE SECURITY IN CLOUD COMPUTINGDISTRIBUTED SCHEME TO AUTHENTICATE DATA STORAGE SECURITY IN CLOUD COMPUTING
DISTRIBUTED SCHEME TO AUTHENTICATE DATA STORAGE SECURITY IN CLOUD COMPUTING
 
DISTRIBUTED SCHEME TO AUTHENTICATE DATA STORAGE SECURITY IN CLOUD COMPUTING
DISTRIBUTED SCHEME TO AUTHENTICATE DATA STORAGE SECURITY IN CLOUD COMPUTINGDISTRIBUTED SCHEME TO AUTHENTICATE DATA STORAGE SECURITY IN CLOUD COMPUTING
DISTRIBUTED SCHEME TO AUTHENTICATE DATA STORAGE SECURITY IN CLOUD COMPUTING
 
Microsoft Sync Framework (part 1) ABTO Software Lecture Garntsarik
Microsoft Sync Framework (part 1) ABTO Software Lecture GarntsarikMicrosoft Sync Framework (part 1) ABTO Software Lecture Garntsarik
Microsoft Sync Framework (part 1) ABTO Software Lecture Garntsarik
 
Distribute Storage System May-2014
Distribute Storage System May-2014Distribute Storage System May-2014
Distribute Storage System May-2014
 

Mais 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 3 c
Ajs 3 cAjs 3 c
Ajs 3 c
 
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
 
Dacj 1-3 b
Dacj 1-3 bDacj 1-3 b
Dacj 1-3 b
 
Dacj 1-3 a
Dacj 1-3 aDacj 1-3 a
Dacj 1-3 a
 
Dacj 1-2 c
Dacj 1-2 cDacj 1-2 c
Dacj 1-2 c
 
Dacj 1-2 a
Dacj 1-2 aDacj 1-2 a
Dacj 1-2 a
 

Último

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?XfilesPro
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 

Último (20)

08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?How to Remove Document Management Hurdles with X-Docs?
How to Remove Document Management Hurdles with X-Docs?
 
Pigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food ManufacturingPigging Solutions in Pet Food Manufacturing
Pigging Solutions in Pet Food Manufacturing
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 

Vb net xp_07

  • 1. Performing Data Updates Objectives In this lesson, you will learn to: Perform cached data updates Perform direct data updates Identify the need for concurrency management Identify the methods of maintaining concurrency in datasets ©NIIT Performing Data Updates/Lesson 7/Slide 1 of 25
  • 2. Performing Data Updates Problem Statement 7.D.1 The Diaz Telecommunications Sales Manager needs to view the customer details in a customized format. In addition, the customer details need to be maintained, which involves adding new customer details, and modifying and deleting the existing ones. ©NIIT Performing Data Updates/Lesson 7/Slide 2 of 25
  • 3. Performing Data Updates Task List Identify the data that needs to be maintained. Identify the mechanism to maintain data. Design a Windows Form to maintain the data. Connect to the database. Bind the data to the Windows Form controls. Write the code to maintain the data. Perform data maintenance. ©NIIT Performing Data Updates/Lesson 7/Slide 3 of 25
  • 4. Performing Data Updates Task 1: Identify the data that needs to be maintained. Result: As per the given problem statement, the data to be maintained is as follows: CustID FName LName Address Phone email ©NIIT Performing Data Updates/Lesson 7/Slide 4 of 25
  • 5. Performing Data Updates Task 2: Identify the mechanism to maintain data. Data can be retrieved from a database directly through data commands or cached in datasets. Performing cached data updates Updating the dataset ® While updating the dataset, some events are raised: ® ColumnChanging ® RowChanging ® ColumnChanged ® RowChanged ® RowDeleting ® RowDeleted ©NIIT Performing Data Updates/Lesson 7/Slide 5 of 25
  • 6. Performing Data Updates Task 2: Identify the mechanism to maintain data. (Contd.) ® Whileupdating the dataset, the following information is maintained: ® RowState property ® Unchanged ® Added ® Deleted ® Detached ® Modified ©NIIT Performing Data Updates/Lesson 7/Slide 6 of 25
  • 7. Performing Data Updates Task 2: Identify the mechanism to maintain data. (Contd.) ® DataRowVersion Enumeration ® Original ® Current ® Proposed ® Default ® The changes are committed to the dataset by calling the AcceptChanges()method. Updating the data source ® Thedata source is updated with the changed dataset by calling the Update()method of the data adapter. ©NIIT Performing Data Updates/Lesson 7/Slide 7 of 25
  • 8. Performing Data Updates Just a Minute… 2. When does the RowState property have the value Detached? 3. What is the relationship between the RowState property and the DataRowVersion enumeration? ©NIIT Performing Data Updates/Lesson 7/Slide 8 of 25
  • 9. Performing Data Updates Task 2: Identify the mechanism to maintain data. (Contd.) Performing direct data updates Data commands are can be used to directly update the data source. A data command object can be derived from the OleDbCommand class or the SqlCommand class. For executing a data command, the Connection, CommandText, and the Parameters properties for the data command have to be set. ©NIIT Performing Data Updates/Lesson 7/Slide 9 of 25
  • 10. Performing Data Updates Task 2: Identify the mechanism to maintain data. (Contd.) Result: Since you need to access the data through a dataset, you will perform a cached data update. ©NIIT Performing Data Updates/Lesson 7/Slide 10 of 25
  • 11. Performing Data Updates Just a Minute… 1. In which cases, direct data update is preferred to updates through datasets? 2. Write a code to connect to a database through data commands. ©NIIT Performing Data Updates/Lesson 7/Slide 11 of 25
  • 12. Performing Data Updates Task 3: Design a Windows Form to maintain the data. Task 4: Connect to the database. Task 5: Bind the data to the Windows Form controls. Task 6: Write the code to maintain the data. Task 7: Perform data maintenance. ©NIIT Performing Data Updates/Lesson 7/Slide 12 of 25
  • 13. Performing Data Updates Maintaining Data Concurrency Concurrency control is the process of ensuring that in case many people attempt to modify data in a database at the same time, modifications made by one person do not adversely affect those of another person. Method Description Pessimistic concurrency control In this type of concurrency control, a system of locks applied does not allow users to modify data in a way that affects other users. When a lock is applied, other users cannot perform actions that would conflict with the lock until the owner releases it. Pessimistic control is mainly used in environments where the data contention is high and protecting data with locks is less costly than rolling back transactions in case of concurrency conflicts. Pessimistic concurrency is not possible in a disconnected architecture. ©NIIT Performing Data Updates/Lesson 7/Slide 13 of 25
  • 14. Performing Data Updates Maintaining Data Concurrency (Contd.) Method Description Optimistic concurrency control In this type of concurrency control, the lock is not applied when the users read the data. When the user performs a data update, the system checks to see if the data has been changed by another user after the data was read. If the data has been changed, an error is raised. Optimistic concurrency is used in environments where the data contention is low and protecting data with locks is more costly than rolling back transaction in case of concurrency conflicts. ‘Last in Wins’ concurrency control This type of concurrency control works in a similar way as the optimistic concurrency control, with the difference that the record is updated regardless of whether the record has been changed or not. ©NIIT Performing Data Updates/Lesson 7/Slide 14 of 25
  • 15. Performing Data Updates Maintaining Data Concurrency (Contd.) ADO.NET implements optimistic concurrency by using the following two methods: The Version number method ® Theversion number method requires the record to be updated to have a datetime stamp or a version number column. The saving all values method ® When the data is retrieved, a copy of all fields, that is, the original version is maintained on the client. ©NIIT Performing Data Updates/Lesson 7/Slide 15 of 25
  • 16. Performing Data Updates Just a Minute… What is the difference between the concurrency control through the Saving All method and the Version Number method? ©NIIT Performing Data Updates/Lesson 7/Slide 16 of 25
  • 17. Performing Data Updates Optimistic Concurrency through Data Adapter By default, the data adapters that are created in an application implement optimistic concurrency. ©NIIT Performing Data Updates/Lesson 7/Slide 17 of 25
  • 18. Performing Data Updates Problem Statement 7.P.1 The Sales Manager of Diaz Telecommunications needs to maintain customer details, which involves adding new customer details, and modifying and deleting existing customer details. While adding and modifying details, the application should ensure that no field is left blank. ©NIIT Performing Data Updates/Lesson 7/Slide 18 of 25
  • 19. Performing Data Updates Summary In this lesson, you learned that: Data can be retrieved from a database directly through data commands or can be cached in datasets. When a dataset is used to access data, updating the database consists of two steps, updating the dataset and updating the database. When you make changes to a record in the table, the following events are raised by the DataTable object: ColumnChanging RowChanging ColumnChanged ©NIIT Performing Data Updates/Lesson 7/Slide 19 of 25
  • 20. Performing Data Updates Summary (Contd.) RowChanged RowDeleting RowDeleted The ColumnChanging and RowChanging events raised by the DataTable object are used to validate the dataset while updating it. When changes are made in a dataset, that is, a row is added, deleted, or modified, some information about each update has to be maintained. ©NIIT Performing Data Updates/Lesson 7/Slide 20 of 25
  • 21. Performing Data Updates Summary (Contd.) The data adapter uses the following information while updating the data source: The RowState property — The RowState property of the DataRow object indicates the current state of the record. The DataRowVersion enumeration — A dataset can maintain four versions of a DataRow object: Current, Original, Proposed, and Default. After the changes have been made, they are committed to the dataset by calling the AcceptChanges() method of the dataset to accept the changes made to the dataset. ©NIIT Performing Data Updates/Lesson 7/Slide 21 of 25
  • 22. Performing Data Updates Summary (Contd.) The data source is updated with the changed dataset by calling the Update() method of the OleDbDataAdapter class. Data commands are generally used in the following cases: To work with stored procedures that return a result set, which can be manipulated To access data that is not appropriate for storing in a dataset, such as data with a short life cycle To access read-only data, that is, data that will not be updated A data command object can be derived from the OleDbCommand class or the SqlCommand class. ©NIIT Performing Data Updates/Lesson 7/Slide 22 of 25
  • 23. Performing Data Updates Summary (Contd.) A data command object can be derived from the OleDbCommand class or the SqlCommand class. For executing a data command, the Connection and the CommandText properties for the command have to be set for specifying the connection and the SQL query to be executed to retrieve the data, respectively. ‘Concurrency’ means ‘at the same time’; thus, concurrency management means to decide the action that will take place when multiple users try to update the same record. ©NIIT Performing Data Updates/Lesson 7/Slide 23 of 25
  • 24. Performing Data Updates Summary (Contd.) There are three concurrency management methods available: Pessimistic concurrency control — In this type of concurrency control, a record is not available to other users from the time that a user begins to edit the record till the time that the record is updated in the database. Optimistic concurrency control — In this type of concurrency control, the record is not available to other users only when the record is being updated in the database. When a user tries to update a record that has been changed, an error occurs. ©NIIT Performing Data Updates/Lesson 7/Slide 24 of 25
  • 25. Performing Data Updates Summary (Contd.) Last in Wins concurrency control — This type of concurrency control works similar to the optimistic concurrency control, the only difference being that the record is updated without checking whether the record has been changed or not. When the row is changed and there is an attempt to update the database, ADO.NET uses two methods to determine if any changes have occurred: The Version number method The saving all values method By default, the data adapters that are created in an application implement optimistic concurrency. ©NIIT Performing Data Updates/Lesson 7/Slide 25 of 25