SlideShare una empresa de Scribd logo
1 de 21
Descargar para leer sin conexión
CIS266

FINAL REVIEW
Use the DataSet object

 To transfer data between tiers
 To manipulate the data without an open
  connection
 To relate data from multiple sources
 To bind data to a Windows form
Referring to Records, Fields

 Actual data values are held in DataRow
  objects
   Each Table object in a dataset has a DataRows
    collection made up of DataRow objects
 Data values are held in the DataRow.Items
  collection
   Refer to fields by index position or by name (string
    value)
Setting a Relationship

 A DataRelation object describes the
  relationship between the tables.
 Use the XML schema (.xsd) file for the dataset
  to create the relationship – or – use code to
  create a relation
 DataRelation Object Functions
   Relating tables
   Setting up constraints
Retrieving Related Row(s)

 Use the GetParentRow method to retrieve
  the matching row from the table on the one
  side
 The GetChildRows method returns an array of
  rows from the many table
   May have 0, 1, or more related records
 Use Find method to find a row by its primary
  key value
DataRowState Enumeration

 Used for finding, accessing changed rows
 The HasChanges Method determines if
  changes have been made to a dataset
   Returns a boolean value
 The GetChanges Method is used to retrieve
  datatable rows that have changes
   Use an empty argument to retrieve all changed
    rows OR specify type of changes using
    enumeration values
The Binding Source

 Controls record position within a table
 Assures that all bound controls on a form
  display data from the same record
 Can bind controls in design time or in code
Binding Source Properties

 Position property holds the current row
  number (zero based)
 Count property indicates the number of
  records in a table
 The Current Property returns the current row
Binding Source Methods

 Binding Source Events
 The CurrentChanged event occurs when a
  bound value is changed
 The PositionChanged event occurs when a
  user navigates to another record
Adding an Event Handler

 An event handler executes automatically
  when an event occurs.
 Need to write event handlers for objects
  declared in code
   Write the procedure you want to execute when
    the event occurs, including the sender and
    eventargs arguments
   Add the handler in another procedure (such as
    constructor), which is called a delegate
     turns the general procedure written into an event
      procedure
DataRow Versions

 The DataRow object maintains several versions
  of its column data
   Current, Original, Default, Proposed
 If no changes have been made, the Current and
  Original versions are the same
 When EndEdit executes, the Current version is
  replaced by the Proposed
 The EndEdit method confirms the changes
 Changes are made when the AcceptChanges
  method executes
Changing Data

 Changes are made to the dataset, not to the
  original data source.
 Execute the data adapter’s Update method
  before calling the AcceptChanges method.
The AcceptChanges Method

 Calls the EndEdit method of the data row
 Removes all rows marked for deletion
 Makes the adds and edits indicated for the table
 Sets the Original version of each changed row to
  the Current version
 Sets RowState of each row to Unchanged
 The RejectChanges replaces Current versions
  with the Original versions
 After AcceptChanges or RejectChanges
  executes, all RowState properties are reset to
  Unchanged
Data Adapter Update Method

 Update writes the changes to the database
  using SQL action queries
 Uses a group of Command Objects
   One each for insert, update and delete
   Can use actual queries or refer to stored
    procedures
When to Update?

 Every time an add, edit, delete occurs?
 When the program terminates?
 Provide a Save option on a menu and prompt
  for unsaved changes when the program
  terminates?
Update Considerations

 Where does the application and data reside?
 How many users can make changes?
 Does the data source need to be up-to-date
  at all times?
Concurrency

 Concurrency control is the process of handling
  conflicts in updates by multiple users.
 Pessimistic concurrency control – a row is
  unavailable from the time the record is retrieved
  until the update is complete
 Optimistic concurrency control – a row is
  unavailable only while an update is in progress
  (default)
 “Last in wins” – A row is unavailable only when
  the update is being made.
Parent/Child Relationships

 To maintain referential integrity, update in
  the following order:
 Delete any child records
 Insert, update, and delete the parent records
 Insert and update the child records
Displaying Related Data

 Use a DataRelation
   Use GetChildRows/GetParentRow methods
   Use a Binding Source that uses a Datarelation as its
    datasource
 Filter rows by
   Using a For loop and adding to an array or datable
   Use table.Select method
 Requery database for related records
   Use Parameter Query; or
   Use a variable and build a Select statement with
    where clause
Stored Procedures

 Can store compiled SQL statement in
  database
   Helps reduce security threats
   Can reduce data passed across network
 Typically work directly with a command
  object
   Need to set command type
   Need to establish connection for command
Parameters

 Stored procedures accept and return values
  through parameters
   Input parameters are similar to arguments in
    procedural languages
 Command object has a parameters collection
  to specify parameters to use with stored
  procedure
 Can use parameters to pass criteria or values
  to edit rows

Más contenido relacionado

La actualidad más candente

VISUAL BASIC .net data accesss vii
VISUAL BASIC .net data accesss viiVISUAL BASIC .net data accesss vii
VISUAL BASIC .net data accesss viiargusacademy
 
ETL Validator Usecase - Validating Measures, Counts with Variance
ETL Validator Usecase - Validating Measures, Counts with VarianceETL Validator Usecase - Validating Measures, Counts with Variance
ETL Validator Usecase - Validating Measures, Counts with VarianceDatagaps Inc
 
10 reasons to use analytics canvas for google analytics data in tableau
10 reasons to use analytics canvas for google analytics data in tableau10 reasons to use analytics canvas for google analytics data in tableau
10 reasons to use analytics canvas for google analytics data in tableaunModal Solutions Inc.
 
asp.net data controls
asp.net data controlsasp.net data controls
asp.net data controlssubakrish
 
Lesson 06 Styles and Templates in WPF
Lesson 06 Styles and Templates in WPFLesson 06 Styles and Templates in WPF
Lesson 06 Styles and Templates in WPFQuang Nguyễn Bá
 
ETL Validator Usecase - Data Profiling and Comparison
ETL Validator Usecase - Data Profiling and ComparisonETL Validator Usecase - Data Profiling and Comparison
ETL Validator Usecase - Data Profiling and ComparisonDatagaps Inc
 
Lesson 09 Resources and Settings in WPF
Lesson 09 Resources and Settings in WPFLesson 09 Resources and Settings in WPF
Lesson 09 Resources and Settings in WPFQuang Nguyễn Bá
 
Stat2 25 09
Stat2 25 09Stat2 25 09
Stat2 25 09stat
 
ETL Validator Usecase - checking for LoV conformance
ETL Validator Usecase - checking for LoV conformanceETL Validator Usecase - checking for LoV conformance
ETL Validator Usecase - checking for LoV conformanceDatagaps Inc
 
SAP BO Web Intelligence Basics
SAP BO Web Intelligence BasicsSAP BO Web Intelligence Basics
SAP BO Web Intelligence BasicsKiran Joy
 
BI-Validator Usecase - Stress Test Plan
BI-Validator Usecase - Stress Test PlanBI-Validator Usecase - Stress Test Plan
BI-Validator Usecase - Stress Test PlanDatagaps Inc
 
ETL Validator Usecase - Transformation logic in input data source
ETL Validator Usecase - Transformation logic in input data sourceETL Validator Usecase - Transformation logic in input data source
ETL Validator Usecase - Transformation logic in input data sourceDatagaps Inc
 
How to view your website stats in tableau
How to view your website stats in tableauHow to view your website stats in tableau
How to view your website stats in tableauBen Jones
 
WPF DATA BINDING CHEATSHEET V1.1
WPF DATA BINDING CHEATSHEET V1.1WPF DATA BINDING CHEATSHEET V1.1
WPF DATA BINDING CHEATSHEET V1.1Vikas Pandey
 
ETL Validator Usecase -Metadata Comparison
ETL Validator Usecase -Metadata ComparisonETL Validator Usecase -Metadata Comparison
ETL Validator Usecase -Metadata ComparisonVasavi Chinta
 

La actualidad más candente (20)

VISUAL BASIC .net data accesss vii
VISUAL BASIC .net data accesss viiVISUAL BASIC .net data accesss vii
VISUAL BASIC .net data accesss vii
 
ETL Validator Usecase - Validating Measures, Counts with Variance
ETL Validator Usecase - Validating Measures, Counts with VarianceETL Validator Usecase - Validating Measures, Counts with Variance
ETL Validator Usecase - Validating Measures, Counts with Variance
 
2310 b 09
2310 b 092310 b 09
2310 b 09
 
10 reasons to use analytics canvas for google analytics data in tableau
10 reasons to use analytics canvas for google analytics data in tableau10 reasons to use analytics canvas for google analytics data in tableau
10 reasons to use analytics canvas for google analytics data in tableau
 
asp.net data controls
asp.net data controlsasp.net data controls
asp.net data controls
 
Lesson 06 Styles and Templates in WPF
Lesson 06 Styles and Templates in WPFLesson 06 Styles and Templates in WPF
Lesson 06 Styles and Templates in WPF
 
Lesson 05 Data Binding in WPF
Lesson 05 Data Binding in WPFLesson 05 Data Binding in WPF
Lesson 05 Data Binding in WPF
 
ETL Validator Usecase - Data Profiling and Comparison
ETL Validator Usecase - Data Profiling and ComparisonETL Validator Usecase - Data Profiling and Comparison
ETL Validator Usecase - Data Profiling and Comparison
 
Lesson 09 Resources and Settings in WPF
Lesson 09 Resources and Settings in WPFLesson 09 Resources and Settings in WPF
Lesson 09 Resources and Settings in WPF
 
Stat2 25 09
Stat2 25 09Stat2 25 09
Stat2 25 09
 
ETL Validator Usecase - checking for LoV conformance
ETL Validator Usecase - checking for LoV conformanceETL Validator Usecase - checking for LoV conformance
ETL Validator Usecase - checking for LoV conformance
 
SAP BO Web Intelligence Basics
SAP BO Web Intelligence BasicsSAP BO Web Intelligence Basics
SAP BO Web Intelligence Basics
 
BI-Validator Usecase - Stress Test Plan
BI-Validator Usecase - Stress Test PlanBI-Validator Usecase - Stress Test Plan
BI-Validator Usecase - Stress Test Plan
 
Chapter.07
Chapter.07Chapter.07
Chapter.07
 
ETL Validator Usecase - Transformation logic in input data source
ETL Validator Usecase - Transformation logic in input data sourceETL Validator Usecase - Transformation logic in input data source
ETL Validator Usecase - Transformation logic in input data source
 
Analysis Of Attribute Revelance
Analysis Of Attribute RevelanceAnalysis Of Attribute Revelance
Analysis Of Attribute Revelance
 
How to view your website stats in tableau
How to view your website stats in tableauHow to view your website stats in tableau
How to view your website stats in tableau
 
WPF DATA BINDING CHEATSHEET V1.1
WPF DATA BINDING CHEATSHEET V1.1WPF DATA BINDING CHEATSHEET V1.1
WPF DATA BINDING CHEATSHEET V1.1
 
ETL Validator Usecase -Metadata Comparison
ETL Validator Usecase -Metadata ComparisonETL Validator Usecase -Metadata Comparison
ETL Validator Usecase -Metadata Comparison
 
Tools and connectors
Tools and connectorsTools and connectors
Tools and connectors
 

Similar a Cis266 final review (20)

Windows Mobile 5.0 Data Access And Storage Webcast
Windows Mobile 5.0 Data Access And Storage WebcastWindows Mobile 5.0 Data Access And Storage Webcast
Windows Mobile 5.0 Data Access And Storage Webcast
 
Mapping Data Flows Training deck Q1 CY22
Mapping Data Flows Training deck Q1 CY22Mapping Data Flows Training deck Q1 CY22
Mapping Data Flows Training deck Q1 CY22
 
Azure Data Factory Data Flows Training (Sept 2020 Update)
Azure Data Factory Data Flows Training (Sept 2020 Update)Azure Data Factory Data Flows Training (Sept 2020 Update)
Azure Data Factory Data Flows Training (Sept 2020 Update)
 
Mapping Data Flows Training April 2021
Mapping Data Flows Training April 2021Mapping Data Flows Training April 2021
Mapping Data Flows Training April 2021
 
Ado.net with asp.net
Ado.net with asp.netAdo.net with asp.net
Ado.net with asp.net
 
CIS 282 Final Review
CIS 282 Final ReviewCIS 282 Final Review
CIS 282 Final Review
 
Dev308
Dev308Dev308
Dev308
 
SSIS 2008 R2 data flow
SSIS 2008 R2 data flowSSIS 2008 R2 data flow
SSIS 2008 R2 data flow
 
SQL Server Stored procedures
SQL Server Stored proceduresSQL Server Stored procedures
SQL Server Stored procedures
 
Chapter 10
Chapter 10Chapter 10
Chapter 10
 
QTP Automation Testing Tutorial 7
QTP Automation Testing Tutorial 7QTP Automation Testing Tutorial 7
QTP Automation Testing Tutorial 7
 
AWS RDS Migration Tool
AWS RDS Migration Tool AWS RDS Migration Tool
AWS RDS Migration Tool
 
Disconnected Architecture and Crystal report in VB.NET
Disconnected Architecture and Crystal report in VB.NETDisconnected Architecture and Crystal report in VB.NET
Disconnected Architecture and Crystal report in VB.NET
 
Ado.net
Ado.netAdo.net
Ado.net
 
Ado Net
Ado NetAdo Net
Ado Net
 
ADO.Net Improvements in .Net 2.0
ADO.Net Improvements in .Net 2.0ADO.Net Improvements in .Net 2.0
ADO.Net Improvements in .Net 2.0
 
ADO .Net
ADO .Net ADO .Net
ADO .Net
 
Ado.net
Ado.netAdo.net
Ado.net
 
Chapter 15
Chapter 15Chapter 15
Chapter 15
 
Stored procedures
Stored proceduresStored procedures
Stored procedures
 

Más de Randy Riness @ South Puget Sound Community College

Más de Randy Riness @ South Puget Sound Community College (20)

Stored procedures
Stored proceduresStored procedures
Stored procedures
 
3 sql overview
3 sql overview3 sql overview
3 sql overview
 
Normalization
NormalizationNormalization
Normalization
 
CIS160 final review
CIS160 final reviewCIS160 final review
CIS160 final review
 
SQL Constraints
SQL ConstraintsSQL Constraints
SQL Constraints
 
CIS 245 Final Review
CIS 245 Final ReviewCIS 245 Final Review
CIS 245 Final Review
 
CIS145 Final Review
CIS145 Final ReviewCIS145 Final Review
CIS145 Final Review
 
Cis166 Final Review C#
Cis166 Final Review C#Cis166 Final Review C#
Cis166 Final Review C#
 
Classes and Objects
Classes and ObjectsClasses and Objects
Classes and Objects
 
CIS245 sql
CIS245 sqlCIS245 sql
CIS245 sql
 
Cis245 Midterm Review
Cis245 Midterm ReviewCis245 Midterm Review
Cis245 Midterm Review
 
CSS
CSSCSS
CSS
 
XPath
XPathXPath
XPath
 
XSLT Overview
XSLT OverviewXSLT Overview
XSLT Overview
 
Views
ViewsViews
Views
 
CIS282 Midterm review
CIS282 Midterm reviewCIS282 Midterm review
CIS282 Midterm review
 
Schemas 2 - Restricting Values
Schemas 2 - Restricting ValuesSchemas 2 - Restricting Values
Schemas 2 - Restricting Values
 
CIS 145 test 1 review
CIS 145 test 1 reviewCIS 145 test 1 review
CIS 145 test 1 review
 
XML schemas
XML schemasXML schemas
XML schemas
 
Document type definitions part 2
Document type definitions part 2Document type definitions part 2
Document type definitions part 2
 

Último

P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfP4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfYu Kanazawa / Osaka University
 
General views of Histopathology and step
General views of Histopathology and stepGeneral views of Histopathology and step
General views of Histopathology and stepobaje godwin sunday
 
Ultra structure and life cycle of Plasmodium.pptx
Ultra structure and life cycle of Plasmodium.pptxUltra structure and life cycle of Plasmodium.pptx
Ultra structure and life cycle of Plasmodium.pptxDr. Asif Anas
 
How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17Celine George
 
Diploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdfDiploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdfMohonDas
 
How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17Celine George
 
CapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptxCapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptxCapitolTechU
 
In - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptxIn - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptxAditiChauhan701637
 
Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.EnglishCEIPdeSigeiro
 
3.21.24 The Origins of Black Power.pptx
3.21.24  The Origins of Black Power.pptx3.21.24  The Origins of Black Power.pptx
3.21.24 The Origins of Black Power.pptxmary850239
 
Practical Research 1 Lesson 9 Scope and delimitation.pptx
Practical Research 1 Lesson 9 Scope and delimitation.pptxPractical Research 1 Lesson 9 Scope and delimitation.pptx
Practical Research 1 Lesson 9 Scope and delimitation.pptxKatherine Villaluna
 
UKCGE Parental Leave Discussion March 2024
UKCGE Parental Leave Discussion March 2024UKCGE Parental Leave Discussion March 2024
UKCGE Parental Leave Discussion March 2024UKCGE
 
Quality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICEQuality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICESayali Powar
 
How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17Celine George
 
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptxPISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptxEduSkills OECD
 
Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...raviapr7
 
Benefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive EducationBenefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive EducationMJDuyan
 
Prescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptxPrescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptxraviapr7
 
The Stolen Bacillus by Herbert George Wells
The Stolen Bacillus by Herbert George WellsThe Stolen Bacillus by Herbert George Wells
The Stolen Bacillus by Herbert George WellsEugene Lysak
 

Último (20)

P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdfP4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
P4C x ELT = P4ELT: Its Theoretical Background (Kanazawa, 2024 March).pdf
 
General views of Histopathology and step
General views of Histopathology and stepGeneral views of Histopathology and step
General views of Histopathology and step
 
Ultra structure and life cycle of Plasmodium.pptx
Ultra structure and life cycle of Plasmodium.pptxUltra structure and life cycle of Plasmodium.pptx
Ultra structure and life cycle of Plasmodium.pptx
 
How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17How to Add a New Field in Existing Kanban View in Odoo 17
How to Add a New Field in Existing Kanban View in Odoo 17
 
Diploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdfDiploma in Nursing Admission Test Question Solution 2023.pdf
Diploma in Nursing Admission Test Question Solution 2023.pdf
 
How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17How to Make a Field read-only in Odoo 17
How to Make a Field read-only in Odoo 17
 
CapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptxCapTechU Doctoral Presentation -March 2024 slides.pptx
CapTechU Doctoral Presentation -March 2024 slides.pptx
 
In - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptxIn - Vivo and In - Vitro Correlation.pptx
In - Vivo and In - Vitro Correlation.pptx
 
Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.Easter in the USA presentation by Chloe.
Easter in the USA presentation by Chloe.
 
3.21.24 The Origins of Black Power.pptx
3.21.24  The Origins of Black Power.pptx3.21.24  The Origins of Black Power.pptx
3.21.24 The Origins of Black Power.pptx
 
Practical Research 1 Lesson 9 Scope and delimitation.pptx
Practical Research 1 Lesson 9 Scope and delimitation.pptxPractical Research 1 Lesson 9 Scope and delimitation.pptx
Practical Research 1 Lesson 9 Scope and delimitation.pptx
 
UKCGE Parental Leave Discussion March 2024
UKCGE Parental Leave Discussion March 2024UKCGE Parental Leave Discussion March 2024
UKCGE Parental Leave Discussion March 2024
 
Quality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICEQuality Assurance_GOOD LABORATORY PRACTICE
Quality Assurance_GOOD LABORATORY PRACTICE
 
How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17How to Show Error_Warning Messages in Odoo 17
How to Show Error_Warning Messages in Odoo 17
 
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptxPISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
PISA-VET launch_El Iza Mohamedou_19 March 2024.pptx
 
Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...Patient Counselling. Definition of patient counseling; steps involved in pati...
Patient Counselling. Definition of patient counseling; steps involved in pati...
 
Benefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive EducationBenefits & Challenges of Inclusive Education
Benefits & Challenges of Inclusive Education
 
Prescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptxPrescribed medication order and communication skills.pptx
Prescribed medication order and communication skills.pptx
 
Personal Resilience in Project Management 2 - TV Edit 1a.pdf
Personal Resilience in Project Management 2 - TV Edit 1a.pdfPersonal Resilience in Project Management 2 - TV Edit 1a.pdf
Personal Resilience in Project Management 2 - TV Edit 1a.pdf
 
The Stolen Bacillus by Herbert George Wells
The Stolen Bacillus by Herbert George WellsThe Stolen Bacillus by Herbert George Wells
The Stolen Bacillus by Herbert George Wells
 

Cis266 final review

  • 2. Use the DataSet object  To transfer data between tiers  To manipulate the data without an open connection  To relate data from multiple sources  To bind data to a Windows form
  • 3. Referring to Records, Fields  Actual data values are held in DataRow objects  Each Table object in a dataset has a DataRows collection made up of DataRow objects  Data values are held in the DataRow.Items collection  Refer to fields by index position or by name (string value)
  • 4. Setting a Relationship  A DataRelation object describes the relationship between the tables.  Use the XML schema (.xsd) file for the dataset to create the relationship – or – use code to create a relation  DataRelation Object Functions  Relating tables  Setting up constraints
  • 5. Retrieving Related Row(s)  Use the GetParentRow method to retrieve the matching row from the table on the one side  The GetChildRows method returns an array of rows from the many table  May have 0, 1, or more related records  Use Find method to find a row by its primary key value
  • 6. DataRowState Enumeration  Used for finding, accessing changed rows  The HasChanges Method determines if changes have been made to a dataset  Returns a boolean value  The GetChanges Method is used to retrieve datatable rows that have changes  Use an empty argument to retrieve all changed rows OR specify type of changes using enumeration values
  • 7. The Binding Source  Controls record position within a table  Assures that all bound controls on a form display data from the same record  Can bind controls in design time or in code
  • 8. Binding Source Properties  Position property holds the current row number (zero based)  Count property indicates the number of records in a table  The Current Property returns the current row
  • 9. Binding Source Methods  Binding Source Events  The CurrentChanged event occurs when a bound value is changed  The PositionChanged event occurs when a user navigates to another record
  • 10. Adding an Event Handler  An event handler executes automatically when an event occurs.  Need to write event handlers for objects declared in code  Write the procedure you want to execute when the event occurs, including the sender and eventargs arguments  Add the handler in another procedure (such as constructor), which is called a delegate  turns the general procedure written into an event procedure
  • 11. DataRow Versions  The DataRow object maintains several versions of its column data  Current, Original, Default, Proposed  If no changes have been made, the Current and Original versions are the same  When EndEdit executes, the Current version is replaced by the Proposed  The EndEdit method confirms the changes  Changes are made when the AcceptChanges method executes
  • 12. Changing Data  Changes are made to the dataset, not to the original data source.  Execute the data adapter’s Update method before calling the AcceptChanges method.
  • 13. The AcceptChanges Method  Calls the EndEdit method of the data row  Removes all rows marked for deletion  Makes the adds and edits indicated for the table  Sets the Original version of each changed row to the Current version  Sets RowState of each row to Unchanged  The RejectChanges replaces Current versions with the Original versions  After AcceptChanges or RejectChanges executes, all RowState properties are reset to Unchanged
  • 14. Data Adapter Update Method  Update writes the changes to the database using SQL action queries  Uses a group of Command Objects  One each for insert, update and delete  Can use actual queries or refer to stored procedures
  • 15. When to Update?  Every time an add, edit, delete occurs?  When the program terminates?  Provide a Save option on a menu and prompt for unsaved changes when the program terminates?
  • 16. Update Considerations  Where does the application and data reside?  How many users can make changes?  Does the data source need to be up-to-date at all times?
  • 17. Concurrency  Concurrency control is the process of handling conflicts in updates by multiple users.  Pessimistic concurrency control – a row is unavailable from the time the record is retrieved until the update is complete  Optimistic concurrency control – a row is unavailable only while an update is in progress (default)  “Last in wins” – A row is unavailable only when the update is being made.
  • 18. Parent/Child Relationships  To maintain referential integrity, update in the following order:  Delete any child records  Insert, update, and delete the parent records  Insert and update the child records
  • 19. Displaying Related Data  Use a DataRelation  Use GetChildRows/GetParentRow methods  Use a Binding Source that uses a Datarelation as its datasource  Filter rows by  Using a For loop and adding to an array or datable  Use table.Select method  Requery database for related records  Use Parameter Query; or  Use a variable and build a Select statement with where clause
  • 20. Stored Procedures  Can store compiled SQL statement in database  Helps reduce security threats  Can reduce data passed across network  Typically work directly with a command object  Need to set command type  Need to establish connection for command
  • 21. Parameters  Stored procedures accept and return values through parameters  Input parameters are similar to arguments in procedural languages  Command object has a parameters collection to specify parameters to use with stored procedure  Can use parameters to pass criteria or values to edit rows

Notas del editor

  1. 06/10/10 CIS-266 Final Review
  2. 06/10/10 CIS-266 Final Review