SlideShare una empresa de Scribd logo
1 de 25
Performing Data Updates


Pre-Assessment Questions
   1.   Consider the following statements:
        • Statement A: Complex data binding is the process of binding a control.
        • Statement B: Simple data binding is the process of binding a
            component.
        Which of the following is correct with respect to the above statements?
        a.  Both, Statement A and Statement B, are False.
        b.   Both, Statement A and Statement B, are True.
        c.   Statement A is True and Statement B is False.
        d.   Statement A is False and Statement B is True.




©NIIT       Creating Data Centric Application Using ADO.NET   Lesson 2A / Slide 1 of 25
Performing Data Updates


Pre-Assessment Questions (Contd.)
   2.   Consider the following statements:
        • Statement A: When user click the DataSource property of the DataGrid
            control, the drop-down list displays the <dataset.table name> option as
            well as the <dataset name> option.
        • Statement B: The CurrencyManager class is derived from the
            BindingManagerBase class.
        Which of the following is correct with respect to the above statements?
        a.  Both, Statement A and Statement B, are False.
        b.   Both, Statement A and Statement B, are True.
        c.   Statement A is True and Statement B is False.
        d.   Statement A is False and Statement B is True.




©NIIT       Creating Data Centric Application Using ADO.NET   Lesson 2A / Slide 2 of 25
Performing Data Updates


Pre-Assessment Questions (Contd.)
   3.   Consider the following statements:
        • Statement A: By using parameterized queries, data can be filtered
            based on the criterion entered by a user at run time.
        • Statement B: Parameterized queries cannot created while configuring
            data adapters.
        Which of the following is correct with respect to the above statements?
        a.  Both, Statement A and Statement B, are False.
        b.   Both, Statement A and Statement B, are True.
        c.   Statement A is True and Statement B is False.
        d.   Statement A is False and Statement B is True.




©NIIT       Creating Data Centric Application Using ADO.NET   Lesson 2A / Slide 3 of 25
Performing Data Updates


Pre-Assessment Questions (Contd.)
   4.   Consider the following statements:
        • Statement A: Data in a dataset can be filtered using the Select()
            method.
        • Statement B: Select method is a member of DataTable class.
        Which of the following is correct with respect to the above statements?
        a.  Both, Statement A and Statement B, are False.
        b.   Both, Statement A and Statement B, are True.
        c.   Statement A is True and Statement B is False.
        d.   Statement A is False and Statement B is True.




©NIIT       Creating Data Centric Application Using ADO.NET   Lesson 2A / Slide 4 of 25
Performing Data Updates


Pre-Assessment Questions (Contd.)
   5.   Consider the following statements:
        • Statement A: By default, every table in a dataset has a data view
            attached to it.
        • Statement B: User cannot create the DataView objects in applications
            explicitly.
        Which of the following is correct with respect to the above statements?
        a.  Both, Statement A and Statement B, are False.
        b.   Both, Statement A and Statement B, are True.
        c.   Statement A is True and Statement B is False.
        d.   Statement A is False and Statement B is True.




©NIIT       Creating Data Centric Application Using ADO.NET   Lesson 2A / Slide 5 of 25
Performing Data Updates


Solutions to Pre-Assessment
Questions
        2.   a. Both, Statement A and Statement B, are False.
        3.   b. Both, Statement A and Statement B, are True.
        4.   c. Statement A is True and Statement B is False.
        5.   b. Both, Statement A and Statement B, are True.
        6.   c. Statement A is True and Statement B is False.




©NIIT         Creating Data Centric Application Using ADO.NET   Lesson 2A / Slide 6 of 25
Performing Data Updates


Objectives
   In this lesson, you will learn to:
        • Implement cached data updates
        • Implement direct data updates
        • Maintain data concurrency
        • Display data from multiple tables in a single Windows Form




©NIIT       Creating Data Centric Application Using ADO.NET   Lesson 2A / Slide 7 of 25
Performing Data Updates


Updating Data
   •    ADO.NET enables Windows Form to display data from the database.
   •    Data can be retrieved from database using ADO.NET.
   •    Database also can be updated with the changes user makes using ADO.NET.
   •    Data can be retrieved from a database directly through data commands or
        cached in datasets.




©NIIT      Creating Data Centric Application Using ADO.NET   Lesson 2A / Slide 8 of 25
Performing Data Updates


Cached Data Updates
   •    The sequence of operations that occur during cached data update are:
          • Data from the database is cached in a dataset and presented to a user
            through an application.
          • The user updates the data, that is, adds, deletes, or modifies the data
            through the application.
          • The dataset is updated with the changes that the user makes through the
            application.
          • The changes in the dataset are transferred to the database at the back
            end.
   •    Updating the database consists of two steps, updating the dataset and
        updating the database.




©NIIT        Creating Data Centric Application Using ADO.NET   Lesson 2A / Slide 9 of 25
Performing Data Updates


Updating a Dataset
   •    A dataset can be updated by using their collections, their objects, and their
        methods.
   •    When user make changes to a record in the table, some events are raised by
        the DataTable object that are as follows:
          • ColumnChanging event
          • RowChanging event
          • ColumnChanged event
          • RowChanged event
          • RowDeleting event
          • RowDeleted event




©NIIT         Creating Data Centric Application Using ADO.NET   Lesson 2A / Slide 10 of 25
Performing Data Updates


Using Events to Validate the Data in a
Dataset
   •    The ColumnChanging and RowChanging events
   •    The ColumnChanging event.
   •    The RowChanging event.
   •    The Row property.
   •    Column property
   •    The Row and Column properties
   •    The data adapter needs information regarding each change in the dataset to
        update the data source.




©NIIT        Creating Data Centric Application Using ADO.NET   Lesson 2A / Slide 11 of 25
Performing Data Updates


Using Events to Validate the Data in a
Dataset (Contd.)
   •    Dataset has to be maintain some information while making changes to dataset.
        This is as given below:
          • The RowState property
          • The DataRowVersion enumeration
   •    Call the AcceptChanges() method of the dataset to accept the changes.
   •    When the AcceptChanges() method is called, it overwrites the original version
        of a record with the current version.




©NIIT        Creating Data Centric Application Using ADO.NET   Lesson 2A / Slide 12 of 25
Performing Data Updates


Updating a Data Source
   •    The data source is updated with the changed dataset by calling the Update()
        method of the data adapter.
   •    The data adapter uses the RowState property and the DataRowVersion
        enumeration information of the DataRow object to make the changes in the
        data source.




©NIIT         Creating Data Centric Application Using ADO.NET   Lesson 2A / Slide 13 of 25
Performing Data Updates


Direct Data Updates
   •    Data source also can be accessed directly through data. 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.
   •    For executing a data command, the Connection, CommandText, and the
        Parameters properties for the data command have to be set.
   •    Connection property is set for specifying the connection.
   •    CommandText property is set for the SQL query or the stored procedure to be
        executed to retrieve the data.
   •    Parameters property is set for the parameters for the execution of the
        command.



©NIIT        Creating Data Centric Application Using ADO.NET   Lesson 2A / Slide 14 of 25
Performing Data Updates




                        Demo
                   Maintaining Data




©NIIT   Creating Data Centric Application Using ADO.NET   Lesson 2A / Slide 15 of 25
Performing Data Updates


Problem Statement
   •    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         Creating Data Centric Application Using ADO.NET   Lesson 2A / Slide 16 of 25
Performing Data Updates


Solution
   •    To maintain customer details, you need to perform the following steps:
        1.  Design a Windows Form to update the data.
        2.  Connect to the database.
        3.  Bind the data to the Windows Forms Controls.
        4.  Write the code to update the data.
        5.  Perform data maintenance




©NIIT       Creating Data Centric Application Using ADO.NET   Lesson 2A / Slide 17 of 25
Performing Data Updates


Maintaining Data Concurrency
   •    When many people attempt to modify data in a database at the same time, a
        system of controls must be implemented so that modifications made by one
        person do not adversely affect those of another person, this is called
        concurrency control.
   •    There are three types of concurrency controls:
          • Pessimistic concurrency control
          • Optimistic concurrency control
          • ‘Last in Wins’ concurrency control
   •    ADO.NET implements optimistic concurrency by using two methods Version
        Number Method and Saving All Values Method.




©NIIT        Creating Data Centric Application Using ADO.NET   Lesson 2A / Slide 18 of 25
Performing Data Updates


Optimistic Concurrency through Data
Adapters
   •    To ensure that a data adapter, when configured, implements optimistic
        concurrency, perform the following steps:
        • Drag an OleDbDataAdapter object into the Windows Form.
        • Data Adapter Configuration Wizard starts. On the third screen of
             the wizard, ensure that the Use SQL statements option is selected.
        • On the fourth screen, click the Query Builder button to create a query
             for retrieving data. Select a table and its fields to be displayed.
        • After the table and its fields are selected, click the OK button.
        • Click the Advanced Options button.
        • The Use optimistic concurrency check box is selected by default.
        • Click the OK button. Then, click the Next button. The SQL statements
             for retrieving the data are generated.
        • Click the Finish button to create a data adapter.
©NIIT      Creating Data Centric Application Using ADO.NET   Lesson 2A / Slide 19 of 25
Performing Data Updates


Displaying Data From Multiple Tables
    •   Data can be displayed from two different tables, using relationship. To
        display data from two tables perform the following tasks:
        • Design a Windows Form to display data.
        • Connect to the database.
        • Generate a dataset for the created data adapters.
        • Create a relationship between the tables.
        • From the Solution Explorer window, select the XML schema for the
             dataset that has been created.
        • Double-click the schema dsMasterDetails.xsd to view its structure.
             The dataset structure is displayed.
        • Select View from the menu bar. Then, select Toolbox from the View
             menu. The Toolbox is displayed on the left pane of the screen. Select
             the XML Schema tab of the Toolbox.



©NIIT     Creating Data Centric Application Using ADO.NET   Lesson 2A / Slide 20 of 25
Performing Data Updates


Displaying Data From Multiple Tables
(Contd.)
    •   Drag a Relation control from the XML Schema tab of the Toolbox to an
        table of the dataset. The Edit Relation dialog box is displayed. By default,
        the name of the relationship is <parent table name child table name>.
    •   Set the Parent element, Child element, Key Fields, and Foreign Key
        Fields values in the Edit Relation dialog box and click the OK button.
    •   A Relation icon appears between the two tables, depicting a relationship
        between them. You can modify the relationship by right-clicking the
        Relation icon and choosing the Edit Relation option from the shortcut
        menu.
    •   Bind the data to the Windows Form controls.
    •   Name the DataGrid control and bind it by setting the DataSource property
        and the DataMember property.
    •    Bind the control on forms and write code to fill dataset on load event of
        form.
©NIIT     Creating Data Centric Application Using ADO.NET   Lesson 2A / Slide 21 of 25
Performing Data Updates


Using Stored Procedures
   •    Stored procedures are used for encapsulating database operations in a single
        command.
   •    The ADO.NET Command object provides the Parameters collection for calling
        a stored procedure.
   •    To call a stored procedure, you need to pass the stored procedure name
        followed by parameter arguments as an SQL statement.




©NIIT       Creating Data Centric Application Using ADO.NET   Lesson 2A / Slide 22 of 25
Performing Data Updates


Summary
   In this lesson, you learned that:
   • ADO.NET enables you to display data from the database in a Windows Form.
        The sequence of operations that occur during cached data update is:
        • The dataset is updated with the changes that the user makes through
              the application. At this point, database remains unaffected, as the
              changes are made only in the dataset cache.
        • The user updates the data, that is, adds, deletes, or modifies the data
              through the application.
        • The dataset is updated with the changes that the user makes through
              the application.
        • The changes in the dataset are transferred to the database at the back
              end.
   • A dataset can be updated by using these collections, their objects, and their
        methods.



©NIIT       Creating Data Centric Application Using ADO.NET   Lesson 2A / Slide 23 of 25
Performing Data Updates


Summary (Contd.)
   •    The Rows collection of a DataSet class contains rows of data in a DataRow
        object.
   •    The ColumnChanging and RowChanging events raised by the DataTable
        object are used to validate the values being entered in the dataset while
        updating the dataset.
   •    The RowState property of the DataRow object indicates the current state of
        the record.
   •    The data source is updated with the changed dataset by calling the Update()
        method of the data adapter.
   •    Data commands can be used in the following cases:
        • To work with stored procedures that return a result set
        • To access data that is not appropriate for storing in a dataset



©NIIT       Creating Data Centric Application Using ADO.NET   Lesson 2A / Slide 24 of 25
Performing Data Updates


Summary (Contd.)
   •    To access read-only data, that is, data that will not be updated.
   •    The version number method requires the record to be updated to have a
        datetime stamp or a version number column.
   •    By default, the data adapters that are created in an application implement
        optimistic concurrency.
   •    Tables are stored in a dataset as discrete entities but a relationship can be
        created between the stored tables to display data from the related tables.
   •    You can use stored procedures for encapsulating database operations in a
        single command.
   •    The ADO.NET Command object provides the Parameters collection for calling
        a stored procedure.




©NIIT       Creating Data Centric Application Using ADO.NET   Lesson 2A / Slide 25 of 25

Más contenido relacionado

Destacado

La tecnologia jesica arbelaez
La tecnologia jesica arbelaezLa tecnologia jesica arbelaez
La tecnologia jesica arbelaezdayayyessi530
 
Galileo iClinic e ADI 360, da oggi disponibili anche su Windows 8
Galileo iClinic e ADI 360, da oggi disponibili anche su Windows 8Galileo iClinic e ADI 360, da oggi disponibili anche su Windows 8
Galileo iClinic e ADI 360, da oggi disponibili anche su Windows 8Maria Beatrice Fasano
 
50 palabras y su significado
50 palabras y su significado50 palabras y su significado
50 palabras y su significadoIris Márquez
 
soal ujian kompetensi Tkj 2013
soal ujian kompetensi Tkj 2013soal ujian kompetensi Tkj 2013
soal ujian kompetensi Tkj 2013heri baskoro
 
Guia prático para quebra de dormência de sementes florestais de espécies nat...
 Guia prático para quebra de dormência de sementes florestais de espécies nat... Guia prático para quebra de dormência de sementes florestais de espécies nat...
Guia prático para quebra de dormência de sementes florestais de espécies nat...Rural Pecuária
 
Daños causados por Hormigas Cortadoras (Géneros Atta y Acromyrmex)
Daños causados porHormigas Cortadoras (Géneros Atta y Acromyrmex) Daños causados porHormigas Cortadoras (Géneros Atta y Acromyrmex)
Daños causados por Hormigas Cortadoras (Géneros Atta y Acromyrmex) JOSE YVANOSKY VAZQUEZ CHACON
 
FOUR BAR CHAIN AND INVERSIONS
FOUR BAR CHAIN AND INVERSIONSFOUR BAR CHAIN AND INVERSIONS
FOUR BAR CHAIN AND INVERSIONSsaahil kshatriya
 
Tecidos vegetais
Tecidos vegetaisTecidos vegetais
Tecidos vegetaisturma21
 

Destacado (13)

La tecnologia jesica arbelaez
La tecnologia jesica arbelaezLa tecnologia jesica arbelaez
La tecnologia jesica arbelaez
 
Ecologia
EcologiaEcologia
Ecologia
 
altiplano
altiplanoaltiplano
altiplano
 
02
0202
02
 
Galileo iClinic e ADI 360, da oggi disponibili anche su Windows 8
Galileo iClinic e ADI 360, da oggi disponibili anche su Windows 8Galileo iClinic e ADI 360, da oggi disponibili anche su Windows 8
Galileo iClinic e ADI 360, da oggi disponibili anche su Windows 8
 
50 palabras y su significado
50 palabras y su significado50 palabras y su significado
50 palabras y su significado
 
Origenes estadística
Origenes estadísticaOrigenes estadística
Origenes estadística
 
Beam engine
Beam engineBeam engine
Beam engine
 
soal ujian kompetensi Tkj 2013
soal ujian kompetensi Tkj 2013soal ujian kompetensi Tkj 2013
soal ujian kompetensi Tkj 2013
 
Guia prático para quebra de dormência de sementes florestais de espécies nat...
 Guia prático para quebra de dormência de sementes florestais de espécies nat... Guia prático para quebra de dormência de sementes florestais de espécies nat...
Guia prático para quebra de dormência de sementes florestais de espécies nat...
 
Daños causados por Hormigas Cortadoras (Géneros Atta y Acromyrmex)
Daños causados porHormigas Cortadoras (Géneros Atta y Acromyrmex) Daños causados porHormigas Cortadoras (Géneros Atta y Acromyrmex)
Daños causados por Hormigas Cortadoras (Géneros Atta y Acromyrmex)
 
FOUR BAR CHAIN AND INVERSIONS
FOUR BAR CHAIN AND INVERSIONSFOUR BAR CHAIN AND INVERSIONS
FOUR BAR CHAIN AND INVERSIONS
 
Tecidos vegetais
Tecidos vegetaisTecidos vegetais
Tecidos vegetais
 

Similar a Vb.net session 07

Vb.net session 08
Vb.net session 08Vb.net session 08
Vb.net session 08Niit Care
 
Vb.net session 06
Vb.net session 06Vb.net session 06
Vb.net session 06Niit Care
 
Vb net xp_07
Vb net xp_07Vb net xp_07
Vb net xp_07Niit Care
 
Designing Database Solutions for Microsoft SQL Server 2012 2012 Microsoft 70-...
Designing Database Solutions for Microsoft SQL Server 2012 2012 Microsoft 70-...Designing Database Solutions for Microsoft SQL Server 2012 2012 Microsoft 70-...
Designing Database Solutions for Microsoft SQL Server 2012 2012 Microsoft 70-...ChristopherBow2
 
Day 8.1 system_admin_tasks
Day 8.1 system_admin_tasksDay 8.1 system_admin_tasks
Day 8.1 system_admin_taskstovetrivel
 
Vb.net session 05
Vb.net session 05Vb.net session 05
Vb.net session 05Niit Care
 
Ado.net session01
Ado.net session01Ado.net session01
Ado.net session01Niit Care
 
06 asp.net session08
06 asp.net session0806 asp.net session08
06 asp.net session08Mani Chaubey
 
Databind in asp.net
Databind in asp.netDatabind in asp.net
Databind in asp.netSireesh K
 
Work with data in ASP.NET
Work with data in ASP.NETWork with data in ASP.NET
Work with data in ASP.NETPeter Gfader
 
SCWCD : Web tier design CHAP : 11
SCWCD : Web tier design CHAP : 11SCWCD : Web tier design CHAP : 11
SCWCD : Web tier design CHAP : 11Ben Abdallah Helmi
 
IT 505 Final Submission Operating System Upgrade Implementation Brief
IT 505 Final Submission Operating System Upgrade Implementation BriefIT 505 Final Submission Operating System Upgrade Implementation Brief
IT 505 Final Submission Operating System Upgrade Implementation BriefEmmaDrinmk
 
Innovize it for_db2_empowering the dba_april_2016
Innovize it for_db2_empowering the dba_april_2016Innovize it for_db2_empowering the dba_april_2016
Innovize it for_db2_empowering the dba_april_2016Eliezer Harkavi
 
Oracle Certification 1Z0-1041 Questions and Answers
Oracle Certification 1Z0-1041 Questions and AnswersOracle Certification 1Z0-1041 Questions and Answers
Oracle Certification 1Z0-1041 Questions and Answersdouglascarnicelli
 
Connect 2014 - CUST109 - planning and upgrading to ibm connections 4.5 succes...
Connect 2014 - CUST109 - planning and upgrading to ibm connections 4.5 succes...Connect 2014 - CUST109 - planning and upgrading to ibm connections 4.5 succes...
Connect 2014 - CUST109 - planning and upgrading to ibm connections 4.5 succes...Martin Schmidt
 
Sql portfolio admin_practicals
Sql portfolio admin_practicalsSql portfolio admin_practicals
Sql portfolio admin_practicalsShelli Ciaschini
 
Vb net xp_06
Vb net xp_06Vb net xp_06
Vb net xp_06Niit Care
 
Oracle data capture c dc
Oracle data capture c dcOracle data capture c dc
Oracle data capture c dcAmit Sharma
 

Similar a Vb.net session 07 (20)

Vb.net session 08
Vb.net session 08Vb.net session 08
Vb.net session 08
 
Vb.net session 06
Vb.net session 06Vb.net session 06
Vb.net session 06
 
Vb net xp_07
Vb net xp_07Vb net xp_07
Vb net xp_07
 
Designing Database Solutions for Microsoft SQL Server 2012 2012 Microsoft 70-...
Designing Database Solutions for Microsoft SQL Server 2012 2012 Microsoft 70-...Designing Database Solutions for Microsoft SQL Server 2012 2012 Microsoft 70-...
Designing Database Solutions for Microsoft SQL Server 2012 2012 Microsoft 70-...
 
Day 8.1 system_admin_tasks
Day 8.1 system_admin_tasksDay 8.1 system_admin_tasks
Day 8.1 system_admin_tasks
 
Vb.net session 05
Vb.net session 05Vb.net session 05
Vb.net session 05
 
Ado.net session01
Ado.net session01Ado.net session01
Ado.net session01
 
06 asp.net session08
06 asp.net session0806 asp.net session08
06 asp.net session08
 
Crystal report
Crystal reportCrystal report
Crystal report
 
Databind in asp.net
Databind in asp.netDatabind in asp.net
Databind in asp.net
 
Work with data in ASP.NET
Work with data in ASP.NETWork with data in ASP.NET
Work with data in ASP.NET
 
SCWCD : Web tier design CHAP : 11
SCWCD : Web tier design CHAP : 11SCWCD : Web tier design CHAP : 11
SCWCD : Web tier design CHAP : 11
 
IT 505 Final Submission Operating System Upgrade Implementation Brief
IT 505 Final Submission Operating System Upgrade Implementation BriefIT 505 Final Submission Operating System Upgrade Implementation Brief
IT 505 Final Submission Operating System Upgrade Implementation Brief
 
Innovize it for_db2_empowering the dba_april_2016
Innovize it for_db2_empowering the dba_april_2016Innovize it for_db2_empowering the dba_april_2016
Innovize it for_db2_empowering the dba_april_2016
 
Oracle Certification 1Z0-1041 Questions and Answers
Oracle Certification 1Z0-1041 Questions and AnswersOracle Certification 1Z0-1041 Questions and Answers
Oracle Certification 1Z0-1041 Questions and Answers
 
Connect 2014 - CUST109 - planning and upgrading to ibm connections 4.5 succes...
Connect 2014 - CUST109 - planning and upgrading to ibm connections 4.5 succes...Connect 2014 - CUST109 - planning and upgrading to ibm connections 4.5 succes...
Connect 2014 - CUST109 - planning and upgrading to ibm connections 4.5 succes...
 
4 h0 002
4 h0 0024 h0 002
4 h0 002
 
Sql portfolio admin_practicals
Sql portfolio admin_practicalsSql portfolio admin_practicals
Sql portfolio admin_practicals
 
Vb net xp_06
Vb net xp_06Vb net xp_06
Vb net xp_06
 
Oracle data capture c dc
Oracle data capture c dcOracle data capture c dc
Oracle data capture c dc
 

Más 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
 

Último

Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024Lonnie McRorey
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxLoriGlavin3
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024BookNet Canada
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxLoriGlavin3
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionDilum Bandara
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek SchlawackFwdays
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxLoriGlavin3
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.Curtis Poe
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersRaghuram Pandurangan
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfPrecisely
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 

Último (20)

Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024TeamStation AI System Report LATAM IT Salaries 2024
TeamStation AI System Report LATAM IT Salaries 2024
 
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptxThe Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
The Fit for Passkeys for Employee and Consumer Sign-ins: FIDO Paris Seminar.pptx
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: Loan Stars - Tech Forum 2024
 
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptxDigital Identity is Under Attack: FIDO Paris Seminar.pptx
Digital Identity is Under Attack: FIDO Paris Seminar.pptx
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
Advanced Computer Architecture – An Introduction
Advanced Computer Architecture – An IntroductionAdvanced Computer Architecture – An Introduction
Advanced Computer Architecture – An Introduction
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
"Subclassing and Composition – A Pythonic Tour of Trade-Offs", Hynek Schlawack
 
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptxPasskey Providers and Enabling Portability: FIDO Paris Seminar.pptx
Passkey Providers and Enabling Portability: FIDO Paris Seminar.pptx
 
How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.How AI, OpenAI, and ChatGPT impact business and software.
How AI, OpenAI, and ChatGPT impact business and software.
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Generative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information DevelopersGenerative AI for Technical Writer or Information Developers
Generative AI for Technical Writer or Information Developers
 
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdfHyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
Hyperautomation and AI/ML: A Strategy for Digital Transformation Success.pdf
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 

Vb.net session 07

  • 1. Performing Data Updates Pre-Assessment Questions 1. Consider the following statements: • Statement A: Complex data binding is the process of binding a control. • Statement B: Simple data binding is the process of binding a component. Which of the following is correct with respect to the above statements? a. Both, Statement A and Statement B, are False. b. Both, Statement A and Statement B, are True. c. Statement A is True and Statement B is False. d. Statement A is False and Statement B is True. ©NIIT Creating Data Centric Application Using ADO.NET Lesson 2A / Slide 1 of 25
  • 2. Performing Data Updates Pre-Assessment Questions (Contd.) 2. Consider the following statements: • Statement A: When user click the DataSource property of the DataGrid control, the drop-down list displays the <dataset.table name> option as well as the <dataset name> option. • Statement B: The CurrencyManager class is derived from the BindingManagerBase class. Which of the following is correct with respect to the above statements? a. Both, Statement A and Statement B, are False. b. Both, Statement A and Statement B, are True. c. Statement A is True and Statement B is False. d. Statement A is False and Statement B is True. ©NIIT Creating Data Centric Application Using ADO.NET Lesson 2A / Slide 2 of 25
  • 3. Performing Data Updates Pre-Assessment Questions (Contd.) 3. Consider the following statements: • Statement A: By using parameterized queries, data can be filtered based on the criterion entered by a user at run time. • Statement B: Parameterized queries cannot created while configuring data adapters. Which of the following is correct with respect to the above statements? a. Both, Statement A and Statement B, are False. b. Both, Statement A and Statement B, are True. c. Statement A is True and Statement B is False. d. Statement A is False and Statement B is True. ©NIIT Creating Data Centric Application Using ADO.NET Lesson 2A / Slide 3 of 25
  • 4. Performing Data Updates Pre-Assessment Questions (Contd.) 4. Consider the following statements: • Statement A: Data in a dataset can be filtered using the Select() method. • Statement B: Select method is a member of DataTable class. Which of the following is correct with respect to the above statements? a. Both, Statement A and Statement B, are False. b. Both, Statement A and Statement B, are True. c. Statement A is True and Statement B is False. d. Statement A is False and Statement B is True. ©NIIT Creating Data Centric Application Using ADO.NET Lesson 2A / Slide 4 of 25
  • 5. Performing Data Updates Pre-Assessment Questions (Contd.) 5. Consider the following statements: • Statement A: By default, every table in a dataset has a data view attached to it. • Statement B: User cannot create the DataView objects in applications explicitly. Which of the following is correct with respect to the above statements? a. Both, Statement A and Statement B, are False. b. Both, Statement A and Statement B, are True. c. Statement A is True and Statement B is False. d. Statement A is False and Statement B is True. ©NIIT Creating Data Centric Application Using ADO.NET Lesson 2A / Slide 5 of 25
  • 6. Performing Data Updates Solutions to Pre-Assessment Questions 2. a. Both, Statement A and Statement B, are False. 3. b. Both, Statement A and Statement B, are True. 4. c. Statement A is True and Statement B is False. 5. b. Both, Statement A and Statement B, are True. 6. c. Statement A is True and Statement B is False. ©NIIT Creating Data Centric Application Using ADO.NET Lesson 2A / Slide 6 of 25
  • 7. Performing Data Updates Objectives In this lesson, you will learn to: • Implement cached data updates • Implement direct data updates • Maintain data concurrency • Display data from multiple tables in a single Windows Form ©NIIT Creating Data Centric Application Using ADO.NET Lesson 2A / Slide 7 of 25
  • 8. Performing Data Updates Updating Data • ADO.NET enables Windows Form to display data from the database. • Data can be retrieved from database using ADO.NET. • Database also can be updated with the changes user makes using ADO.NET. • Data can be retrieved from a database directly through data commands or cached in datasets. ©NIIT Creating Data Centric Application Using ADO.NET Lesson 2A / Slide 8 of 25
  • 9. Performing Data Updates Cached Data Updates • The sequence of operations that occur during cached data update are: • Data from the database is cached in a dataset and presented to a user through an application. • The user updates the data, that is, adds, deletes, or modifies the data through the application. • The dataset is updated with the changes that the user makes through the application. • The changes in the dataset are transferred to the database at the back end. • Updating the database consists of two steps, updating the dataset and updating the database. ©NIIT Creating Data Centric Application Using ADO.NET Lesson 2A / Slide 9 of 25
  • 10. Performing Data Updates Updating a Dataset • A dataset can be updated by using their collections, their objects, and their methods. • When user make changes to a record in the table, some events are raised by the DataTable object that are as follows: • ColumnChanging event • RowChanging event • ColumnChanged event • RowChanged event • RowDeleting event • RowDeleted event ©NIIT Creating Data Centric Application Using ADO.NET Lesson 2A / Slide 10 of 25
  • 11. Performing Data Updates Using Events to Validate the Data in a Dataset • The ColumnChanging and RowChanging events • The ColumnChanging event. • The RowChanging event. • The Row property. • Column property • The Row and Column properties • The data adapter needs information regarding each change in the dataset to update the data source. ©NIIT Creating Data Centric Application Using ADO.NET Lesson 2A / Slide 11 of 25
  • 12. Performing Data Updates Using Events to Validate the Data in a Dataset (Contd.) • Dataset has to be maintain some information while making changes to dataset. This is as given below: • The RowState property • The DataRowVersion enumeration • Call the AcceptChanges() method of the dataset to accept the changes. • When the AcceptChanges() method is called, it overwrites the original version of a record with the current version. ©NIIT Creating Data Centric Application Using ADO.NET Lesson 2A / Slide 12 of 25
  • 13. Performing Data Updates Updating a Data Source • The data source is updated with the changed dataset by calling the Update() method of the data adapter. • The data adapter uses the RowState property and the DataRowVersion enumeration information of the DataRow object to make the changes in the data source. ©NIIT Creating Data Centric Application Using ADO.NET Lesson 2A / Slide 13 of 25
  • 14. Performing Data Updates Direct Data Updates • Data source also can be accessed directly through data. 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. • For executing a data command, the Connection, CommandText, and the Parameters properties for the data command have to be set. • Connection property is set for specifying the connection. • CommandText property is set for the SQL query or the stored procedure to be executed to retrieve the data. • Parameters property is set for the parameters for the execution of the command. ©NIIT Creating Data Centric Application Using ADO.NET Lesson 2A / Slide 14 of 25
  • 15. Performing Data Updates Demo Maintaining Data ©NIIT Creating Data Centric Application Using ADO.NET Lesson 2A / Slide 15 of 25
  • 16. Performing Data Updates Problem Statement • 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 Creating Data Centric Application Using ADO.NET Lesson 2A / Slide 16 of 25
  • 17. Performing Data Updates Solution • To maintain customer details, you need to perform the following steps: 1. Design a Windows Form to update the data. 2. Connect to the database. 3. Bind the data to the Windows Forms Controls. 4. Write the code to update the data. 5. Perform data maintenance ©NIIT Creating Data Centric Application Using ADO.NET Lesson 2A / Slide 17 of 25
  • 18. Performing Data Updates Maintaining Data Concurrency • When many people attempt to modify data in a database at the same time, a system of controls must be implemented so that modifications made by one person do not adversely affect those of another person, this is called concurrency control. • There are three types of concurrency controls: • Pessimistic concurrency control • Optimistic concurrency control • ‘Last in Wins’ concurrency control • ADO.NET implements optimistic concurrency by using two methods Version Number Method and Saving All Values Method. ©NIIT Creating Data Centric Application Using ADO.NET Lesson 2A / Slide 18 of 25
  • 19. Performing Data Updates Optimistic Concurrency through Data Adapters • To ensure that a data adapter, when configured, implements optimistic concurrency, perform the following steps: • Drag an OleDbDataAdapter object into the Windows Form. • Data Adapter Configuration Wizard starts. On the third screen of the wizard, ensure that the Use SQL statements option is selected. • On the fourth screen, click the Query Builder button to create a query for retrieving data. Select a table and its fields to be displayed. • After the table and its fields are selected, click the OK button. • Click the Advanced Options button. • The Use optimistic concurrency check box is selected by default. • Click the OK button. Then, click the Next button. The SQL statements for retrieving the data are generated. • Click the Finish button to create a data adapter. ©NIIT Creating Data Centric Application Using ADO.NET Lesson 2A / Slide 19 of 25
  • 20. Performing Data Updates Displaying Data From Multiple Tables • Data can be displayed from two different tables, using relationship. To display data from two tables perform the following tasks: • Design a Windows Form to display data. • Connect to the database. • Generate a dataset for the created data adapters. • Create a relationship between the tables. • From the Solution Explorer window, select the XML schema for the dataset that has been created. • Double-click the schema dsMasterDetails.xsd to view its structure. The dataset structure is displayed. • Select View from the menu bar. Then, select Toolbox from the View menu. The Toolbox is displayed on the left pane of the screen. Select the XML Schema tab of the Toolbox. ©NIIT Creating Data Centric Application Using ADO.NET Lesson 2A / Slide 20 of 25
  • 21. Performing Data Updates Displaying Data From Multiple Tables (Contd.) • Drag a Relation control from the XML Schema tab of the Toolbox to an table of the dataset. The Edit Relation dialog box is displayed. By default, the name of the relationship is <parent table name child table name>. • Set the Parent element, Child element, Key Fields, and Foreign Key Fields values in the Edit Relation dialog box and click the OK button. • A Relation icon appears between the two tables, depicting a relationship between them. You can modify the relationship by right-clicking the Relation icon and choosing the Edit Relation option from the shortcut menu. • Bind the data to the Windows Form controls. • Name the DataGrid control and bind it by setting the DataSource property and the DataMember property. • Bind the control on forms and write code to fill dataset on load event of form. ©NIIT Creating Data Centric Application Using ADO.NET Lesson 2A / Slide 21 of 25
  • 22. Performing Data Updates Using Stored Procedures • Stored procedures are used for encapsulating database operations in a single command. • The ADO.NET Command object provides the Parameters collection for calling a stored procedure. • To call a stored procedure, you need to pass the stored procedure name followed by parameter arguments as an SQL statement. ©NIIT Creating Data Centric Application Using ADO.NET Lesson 2A / Slide 22 of 25
  • 23. Performing Data Updates Summary In this lesson, you learned that: • ADO.NET enables you to display data from the database in a Windows Form. The sequence of operations that occur during cached data update is: • The dataset is updated with the changes that the user makes through the application. At this point, database remains unaffected, as the changes are made only in the dataset cache. • The user updates the data, that is, adds, deletes, or modifies the data through the application. • The dataset is updated with the changes that the user makes through the application. • The changes in the dataset are transferred to the database at the back end. • A dataset can be updated by using these collections, their objects, and their methods. ©NIIT Creating Data Centric Application Using ADO.NET Lesson 2A / Slide 23 of 25
  • 24. Performing Data Updates Summary (Contd.) • The Rows collection of a DataSet class contains rows of data in a DataRow object. • The ColumnChanging and RowChanging events raised by the DataTable object are used to validate the values being entered in the dataset while updating the dataset. • The RowState property of the DataRow object indicates the current state of the record. • The data source is updated with the changed dataset by calling the Update() method of the data adapter. • Data commands can be used in the following cases: • To work with stored procedures that return a result set • To access data that is not appropriate for storing in a dataset ©NIIT Creating Data Centric Application Using ADO.NET Lesson 2A / Slide 24 of 25
  • 25. Performing Data Updates Summary (Contd.) • To access read-only data, that is, data that will not be updated. • The version number method requires the record to be updated to have a datetime stamp or a version number column. • By default, the data adapters that are created in an application implement optimistic concurrency. • Tables are stored in a dataset as discrete entities but a relationship can be created between the stored tables to display data from the related tables. • You can use stored procedures for encapsulating database operations in a single command. • The ADO.NET Command object provides the Parameters collection for calling a stored procedure. ©NIIT Creating Data Centric Application Using ADO.NET Lesson 2A / Slide 25 of 25