SlideShare una empresa de Scribd logo
1 de 18
Mapping XML to Databases


Objectives
    In this lesson, you will learn to:
         • Map XML to databases
         • Implement various query languages
         • Display data from multiple tables using VC#




 ©NIIT        Creating Data Centric Applications Using ADO.NET   Slide 1 of 18
Mapping XML to Databases


Understanding XML Data Transfer
   •     XML can be used for transferring data from client-side application to a
         server side application and vice versa. Server can host a database or an
         application. The data transfer can happen between applications or
         application and database. XML data transfer can happen in the following
         ways:
          • Map XML to databases
          • Query Languages

   •     Map XML to databases


          •    Mappings form the basis for data transfer between XML documents
               and databases. Following are the two types of mappings:
                • Table-Based Mapping
                • Query Languages


 ©NIIT         Creating Data Centric Applications Using ADO.NET            Slide 2 of 18
Mapping XML to Databases


Understanding XML Data Transfer
(Contd.)
   •     Table-Based Mapping
         • Table-based mapping is used for data transfer between an XML
              document and a relational database. You can also transfer data
              between relational databases by using the table-based mapping.


   •     Object-Relational Mapping


         •   In the object-relational mapping, the data in the XML document is
             organized in a hierarchical manner. This type of mapping is used by
             mostly XML-enabled relational databases such as SQL server.




 ©NIIT          Creating Data Centric Applications Using ADO.NET          Slide 3 of 18
Mapping XML to Databases


Understanding XML Data Transfer
(Contd.)
   •     Query Languages


         •   Query languages are embedded in XML document and are used for
             data transfer between applications.


                  •    Template-Based Query Languages Construction
                  •    SQL-Based Query Languages
                  •    XML Query Languages




 ©NIIT         Creating Data Centric Applications Using ADO.NET      Slide 4 of 18
Mapping XML to Databases


Displaying Data from Multiple Tables
using VC#
   •     Consider an example. An application needs to be created to display a
         Windows Form. The form should display a combo box that comprises all
         Customer IDs. When a user selects a customer ID, the corresponding
         order IDs should be displayed in a list box.
   •     To create an application for the above scenario, perform the following
         steps:
              • Create a Windows application
              • Add a combo box and list box to the form
              • Connect to the database
              • Create the data adapters and connections
              • Generate the Dataset that will contain the related data tables



 ©NIIT          Creating Data Centric Applications Using ADO.NET          Slide 5 of 18
Mapping XML to Databases


Displaying Data from Multiple Tables
using VC#(Contd.)
         •   Create the Relationship.
         •   Fill the combo box with customer Ids.
         •   Fill the dataset with data from the Customers and the Orders table.
         •   Create an event handler to retrieve the order details for a selected
             customer.
         •   Display the related records in the list box.
         •   Follow easy to understand naming conventions for the system and
             processes.
         •   Design the system in such a manner that it meets the immediate
             system requirements and can be modified later for enhanced
             features.
         •   Test the modules.



 ©NIIT         Creating Data Centric Applications Using ADO.NET            Slide 6 of 18
Mapping XML to Databases


   From the Expert’s Desk
         •   This section provides:


             •      Best practices on ADO.NET and Data Access Components
             •      Tips and Tricks
             •      FAQs on Data Binding and Data Reader.




 ©NIIT           Creating Data Centric Applications Using ADO.NET      Slide 7 of 18
Mapping XML to Databases


Best Practices
Applying Best Practices to a Project
   •     The best practices that you can follow in a project are:
         • Use the Appropriate Data-Access Object
         • Use SQL Data Types With SQL Server
         • Use Centralized Data-Access Functions
         • Use Centralized Data-Access Functions




 ©NIIT          Creating Data Centric Applications Using ADO.NET    Slide 8 of 18
Mapping XML to Databases


Tips and Tricks
Establishing Quick Database Connection in .NET

   •     While establishing connection to a database, you may find problems in
         creating the database connection string. Following sites provide connection
         strings that can be used in the applications
         • http://www.connectionstrings.com
         • http://www.able-consulting.com/ADO_Conn.htm




 ©NIIT          Creating Data Centric Applications Using ADO.NET           Slide 9 of 18
Mapping XML to Databases


FAQs
  •      When using the SqlDataReader, how do you know the number of records
         that are found?

         The SqlDataReader provides means of reading a "forward-only" stream of
         rows from a SQL Server database. Therefore, the number of rows read
         from the database is not known until the last row is read.

        This is the same type of problem we had back in classic ADO where the
        Recordset's RecordCount was always -1 for a server-side, forward-only
        cursor. The solution in classic ADO was to use a static or keyset cursor.
  Or use a client-side cursor location, which always used a static cursor.
  However in ADO.NET 1.0, there is no such thing as a server-side,
  static or keyset cursor. There is only the server-side, forward-only
  DataReader. Or there is the client-side, static DataSet.
  •   


 ©NIIT          Creating Data Centric Applications Using ADO.NET            Slide 10 of 18
Mapping XML to Databases

 FAQs(Contd.)
          You can work-around this issue by either Increment a counter while looping
          through all of the rows, or use two SELECT statements in your query. The
          first one returns the row count and the second one returns the actual
     rows. e.g. "SELECT COUNT(*) FROM myTableName; SELECT * FROM
     myTableName". Then you can use the NextResult method to move from the first
     to the second result set, or use a DataSet instead of the
     SqlDataReader. Then use the DataSet‘s Table Rows         count. e.g.
     DataSet.Tables("Products").Rows.Count.

     •   How can I bind a data grid to a relationship through code?

         To bind a data grid to a relationship through code, you set the DataSource
         property to the dataset that contains the relationship, and you set the
     DataMember property to the relationship. You must refer to the relationship
         through its parent table .



 ©NIIT        Creating Data Centric Applications Using ADO.NET         Slide 11 of 18
Mapping XML to Databases


FAQs(Contd.)
          For example, suppose you define a relationship named SalesInvoices that
         relates rows in a parent table named Sales to rows in a child table named
         Invoices. Then, if the relationship and tables are stored in a dataset
         named DsPayables2, you can bind a data grid named grdInvoices to the
         relationship using this code:
                grdInvoices.DataSource = DsPayables2
                grdInvoices.DataMember = "Sales.SalesInvoices"

   •     Why do I get a "Login failed" error message when I try to connect to a
         SQL Server database from a web application?

         This error typically occurs while using Windows NT Integrated security to
         connect to the database. This error occurs because ASP.NET runs as a
         separate Windows process with its own login name: ASPNET.


 ©NIIT          Creating Data Centric Applications Using ADO.NET           Slide 12 of 18
Mapping XML to Databases


FAQs(Contd.)
         When you try to access a SQL Server database from a web application, then,
         ASP.NET will try to use this login name to log in to SQL Server. For that to
         work, you first have to create a Windows user named ASPNET, and you have
         to create a SQL Server user account named ASPNET and grant it access to
         the database. A simpler solution is not to use Windows NT Integrated
         security. Instead, you can name the specific SQL Server account you want
         to use when you create the connection. If you’re using MSDE on your own
         system, for example, you can probably just use the default system
         administrator account, sa.




 ©NIIT        Creating Data Centric Applications Using ADO.NET          Slide 13 of 18
Mapping XML to Databases


Challenge




 ©NIIT   Creating Data Centric Applications Using ADO.NET   Slide 14 of 18
Mapping XML to Databases


Challenge (Contd.)
   •     Across:
                   •   13. Used for connecting to a database, retrieving data, storing
                       the data dataset, reading the retrieved data, and updating the
                       database. (11)
                   •   134. Method of DataTable class to filter data(6)
                   •   142. Language used to define the elements and attributes of
                       XML documents(3)

   •     Down:
                   •   2. Object that creates a fixed customized view of given
                       DataTable object(8)
                   •   4. Provides the bridge between the DataSet object and the data
                       source. (11)
                   •   7. Type of binding, to display multiple values for a column from
                       the dataset rows(7)
                   •   9. ADO.NET uses the ___________ data architecture(12)



 ©NIIT           Creating Data Centric Applications Using ADO.NET          Slide 15 of 18
Mapping XML to Databases


Challenge (Contd.)
         •   12. Component that represents the column that uniquely identifies a
             row in a DataTable(10)
         •   13. A recordset in ADO is similar to a _________ in ADO.NET (7)
         •   22. Used to retrieve data from a data source in a read-only and
             forward-only mode(10)
         •   39. Method used to stop the connection with a data source(5)
         •   41. Represents a table in the DataTableCollection of a dataset(9)
         •   54. Dataset, which does not have any associated XML schema(7)
         •   56. Control, which displays data from multiple records as well as
             multiple columns. (8)
         •   59. Data command to enter data into a database(6)
         •   79. Fundamental format for data transfer in ADO.NET(3)




 ©NIIT       Creating Data Centric Applications Using ADO.NET        Slide 16 of 18
Mapping XML to Databases


Solution to Challenge




 ©NIIT   Creating Data Centric Applications Using ADO.NET   Slide 17 of 18
Mapping XML to Databases


Summary
         •   XML can be used for transferring data from client-side application to a
             server side application and vice versa. Server can host a database or
             an application.
         •   XML data transfer can happen in the following ways:
              • Map XML to databases
              • Query Languages
         •   Query languages are embedded in XML document and are used for
             data transfer between applications.
         •   You can display data from multiple tables using VC#
         •   The best practices that you can follow in a project are:
              • Use the Appropriate Data-Access Object
              • Use SQL Data Types With SQL Server
              • Use Centralized Data-Access Functions
              • Use Centralized Data-Access Functions


 ©NIIT       Creating Data Centric Applications Using ADO.NET          Slide 18 of 18

Más contenido relacionado

Destacado

Mol works diapositivas
Mol works diapositivasMol works diapositivas
Mol works diapositivasalejandro
 
Antropologia argentina
Antropologia argentina Antropologia argentina
Antropologia argentina Roberto Rios
 
Marketing
MarketingMarketing
MarketingLepipi
 
Comp tia n+_session_10
Comp tia n+_session_10Comp tia n+_session_10
Comp tia n+_session_10Niit Care
 
Top branż analizowanych w Top Marce
Top branż analizowanych w Top MarceTop branż analizowanych w Top Marce
Top branż analizowanych w Top MarceBrandDoctor.pl
 
Eaea sofia prsd
 Eaea sofia prsd Eaea sofia prsd
Eaea sofia prsdGIA VER
 
Research and development in Life science and public Health
Research and development in Life science and public HealthResearch and development in Life science and public Health
Research and development in Life science and public HealthAsghar Abbas
 
Prezentacja konres e-handlu 23.10.2014
Prezentacja konres e-handlu 23.10.2014Prezentacja konres e-handlu 23.10.2014
Prezentacja konres e-handlu 23.10.2014BrandDoctor.pl
 
Case study marki LUX MED z Albumu Superbrands Polska 2016
Case study marki LUX MED z Albumu Superbrands Polska 2016 Case study marki LUX MED z Albumu Superbrands Polska 2016
Case study marki LUX MED z Albumu Superbrands Polska 2016 Superbrands Polska
 
TEMA 3. 1º E:SO.Relieve de África 2015.
TEMA 3. 1º E:SO.Relieve de África 2015. TEMA 3. 1º E:SO.Relieve de África 2015.
TEMA 3. 1º E:SO.Relieve de África 2015. Chema R.
 
Tema 2.1ESO . Curso 2016 /2017 El relive terrestre.
Tema 2.1ESO . Curso 2016 /2017 El relive terrestre.Tema 2.1ESO . Curso 2016 /2017 El relive terrestre.
Tema 2.1ESO . Curso 2016 /2017 El relive terrestre.Chema R.
 
Spanish Football Fans' Perception of Competitive Balance in the Spanish Footb...
Spanish Football Fans' Perception of Competitive Balance in the Spanish Footb...Spanish Football Fans' Perception of Competitive Balance in the Spanish Footb...
Spanish Football Fans' Perception of Competitive Balance in the Spanish Footb...Manu Perez Vehi
 
Dec of indep quadrant notes
Dec of indep quadrant notesDec of indep quadrant notes
Dec of indep quadrant notesDavid Poss
 

Destacado (20)

Rnw CV
Rnw CVRnw CV
Rnw CV
 
Mol works diapositivas
Mol works diapositivasMol works diapositivas
Mol works diapositivas
 
Antropologia argentina
Antropologia argentina Antropologia argentina
Antropologia argentina
 
Marketing
MarketingMarketing
Marketing
 
TERCER MILITARISMO.
TERCER MILITARISMO.TERCER MILITARISMO.
TERCER MILITARISMO.
 
Comp tia n+_session_10
Comp tia n+_session_10Comp tia n+_session_10
Comp tia n+_session_10
 
Logistica
LogisticaLogistica
Logistica
 
Top branż analizowanych w Top Marce
Top branż analizowanych w Top MarceTop branż analizowanych w Top Marce
Top branż analizowanych w Top Marce
 
Eaea sofia prsd
 Eaea sofia prsd Eaea sofia prsd
Eaea sofia prsd
 
Research and development in Life science and public Health
Research and development in Life science and public HealthResearch and development in Life science and public Health
Research and development in Life science and public Health
 
Prezentacja konres e-handlu 23.10.2014
Prezentacja konres e-handlu 23.10.2014Prezentacja konres e-handlu 23.10.2014
Prezentacja konres e-handlu 23.10.2014
 
Branding w muzyce: Muzyk 2.0
Branding w muzyce: Muzyk 2.0Branding w muzyce: Muzyk 2.0
Branding w muzyce: Muzyk 2.0
 
19 Materiales Cerámicos II
19 Materiales Cerámicos II19 Materiales Cerámicos II
19 Materiales Cerámicos II
 
Case study marki LUX MED z Albumu Superbrands Polska 2016
Case study marki LUX MED z Albumu Superbrands Polska 2016 Case study marki LUX MED z Albumu Superbrands Polska 2016
Case study marki LUX MED z Albumu Superbrands Polska 2016
 
TEMA 3. 1º E:SO.Relieve de África 2015.
TEMA 3. 1º E:SO.Relieve de África 2015. TEMA 3. 1º E:SO.Relieve de África 2015.
TEMA 3. 1º E:SO.Relieve de África 2015.
 
Tema 2.1ESO . Curso 2016 /2017 El relive terrestre.
Tema 2.1ESO . Curso 2016 /2017 El relive terrestre.Tema 2.1ESO . Curso 2016 /2017 El relive terrestre.
Tema 2.1ESO . Curso 2016 /2017 El relive terrestre.
 
Spanish Football Fans' Perception of Competitive Balance in the Spanish Footb...
Spanish Football Fans' Perception of Competitive Balance in the Spanish Footb...Spanish Football Fans' Perception of Competitive Balance in the Spanish Footb...
Spanish Football Fans' Perception of Competitive Balance in the Spanish Footb...
 
Dec of indep quadrant notes
Dec of indep quadrant notesDec of indep quadrant notes
Dec of indep quadrant notes
 
Hominidos
HominidosHominidos
Hominidos
 
Gametogénesis, espermatogenesis y ovogenesis
Gametogénesis, espermatogenesis y ovogenesisGametogénesis, espermatogenesis y ovogenesis
Gametogénesis, espermatogenesis y ovogenesis
 

Similar a Vb.net session 16

ADO .NET by Sonu Vishwakarma
ADO .NET by Sonu VishwakarmaADO .NET by Sonu Vishwakarma
ADO .NET by Sonu VishwakarmaSonu Vishwakarma
 
Vb.net session 05
Vb.net session 05Vb.net session 05
Vb.net session 05Niit Care
 
Chapter 3: ado.net
Chapter 3: ado.netChapter 3: ado.net
Chapter 3: ado.netNgeam Soly
 
Asp net interview_questions
Asp net interview_questionsAsp net interview_questions
Asp net interview_questionsGhazi Anwar
 
Asp net interview_questions
Asp net interview_questionsAsp net interview_questions
Asp net interview_questionsBilam
 
WEB PROGRAMMING USING ASP.NET
WEB PROGRAMMING USING ASP.NETWEB PROGRAMMING USING ASP.NET
WEB PROGRAMMING USING ASP.NETDhruvVekariya3
 
Introduction to ado
Introduction to adoIntroduction to ado
Introduction to adoHarman Bajwa
 
Visual Basic.Net & Ado.Net
Visual Basic.Net & Ado.NetVisual Basic.Net & Ado.Net
Visual Basic.Net & Ado.NetFaRid Adwa
 
Building N Tier Applications With Entity Framework Services 2010
Building N Tier Applications With Entity Framework Services 2010Building N Tier Applications With Entity Framework Services 2010
Building N Tier Applications With Entity Framework Services 2010David McCarter
 
Ado.net session01
Ado.net session01Ado.net session01
Ado.net session01Niit Care
 
Introduction to ADO.NET
Introduction to ADO.NETIntroduction to ADO.NET
Introduction to ADO.NETrchakra
 
Ch06 ado.net fundamentals
Ch06 ado.net fundamentalsCh06 ado.net fundamentals
Ch06 ado.net fundamentalsMadhuri Kavade
 
Big Data Analytics on the Cloud Oracle Applications AWS Redshift & Tableau
Big Data Analytics on the Cloud Oracle Applications AWS Redshift & TableauBig Data Analytics on the Cloud Oracle Applications AWS Redshift & Tableau
Big Data Analytics on the Cloud Oracle Applications AWS Redshift & TableauSam Palani
 
Simple ado program by visual studio
Simple ado program by visual studioSimple ado program by visual studio
Simple ado program by visual studioAravindharamanan S
 

Similar a Vb.net session 16 (20)

Ado .net
Ado .netAdo .net
Ado .net
 
ADO .NET by Sonu Vishwakarma
ADO .NET by Sonu VishwakarmaADO .NET by Sonu Vishwakarma
ADO .NET by Sonu Vishwakarma
 
Ado
AdoAdo
Ado
 
Vb.net session 05
Vb.net session 05Vb.net session 05
Vb.net session 05
 
Chapter 3: ado.net
Chapter 3: ado.netChapter 3: ado.net
Chapter 3: ado.net
 
Asp net interview_questions
Asp net interview_questionsAsp net interview_questions
Asp net interview_questions
 
Asp net interview_questions
Asp net interview_questionsAsp net interview_questions
Asp net interview_questions
 
WEB PROGRAMMING USING ASP.NET
WEB PROGRAMMING USING ASP.NETWEB PROGRAMMING USING ASP.NET
WEB PROGRAMMING USING ASP.NET
 
Introduction to ado
Introduction to adoIntroduction to ado
Introduction to ado
 
Visual Basic.Net & Ado.Net
Visual Basic.Net & Ado.NetVisual Basic.Net & Ado.Net
Visual Basic.Net & Ado.Net
 
Building N Tier Applications With Entity Framework Services 2010
Building N Tier Applications With Entity Framework Services 2010Building N Tier Applications With Entity Framework Services 2010
Building N Tier Applications With Entity Framework Services 2010
 
Ado.net session01
Ado.net session01Ado.net session01
Ado.net session01
 
ADO.NET
ADO.NETADO.NET
ADO.NET
 
Entity framework
Entity frameworkEntity framework
Entity framework
 
Introduction to ADO.NET
Introduction to ADO.NETIntroduction to ADO.NET
Introduction to ADO.NET
 
Ch06 ado.net fundamentals
Ch06 ado.net fundamentalsCh06 ado.net fundamentals
Ch06 ado.net fundamentals
 
Big Data Analytics on the Cloud Oracle Applications AWS Redshift & Tableau
Big Data Analytics on the Cloud Oracle Applications AWS Redshift & TableauBig Data Analytics on the Cloud Oracle Applications AWS Redshift & Tableau
Big Data Analytics on the Cloud Oracle Applications AWS Redshift & Tableau
 
Crystal report
Crystal reportCrystal report
Crystal report
 
ASP.NET Lecture 4
ASP.NET Lecture 4ASP.NET Lecture 4
ASP.NET Lecture 4
 
Simple ado program by visual studio
Simple ado program by visual studioSimple ado program by visual studio
Simple ado program by visual studio
 

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-a
Dacj 4 2-aDacj 4 2-a
Dacj 4 2-a
 
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

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
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
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
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
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphNeo4j
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
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 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
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
 
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
 
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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAndikSusilo4
 

Último (20)

Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
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
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
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
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge GraphSIEMENS: RAPUNZEL – A Tale About Knowledge Graph
SIEMENS: RAPUNZEL – A Tale About Knowledge Graph
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
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 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?
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 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
 
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
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 
Azure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & ApplicationAzure Monitor & Application Insight to monitor Infrastructure & Application
Azure Monitor & Application Insight to monitor Infrastructure & Application
 

Vb.net session 16

  • 1. Mapping XML to Databases Objectives In this lesson, you will learn to: • Map XML to databases • Implement various query languages • Display data from multiple tables using VC# ©NIIT Creating Data Centric Applications Using ADO.NET Slide 1 of 18
  • 2. Mapping XML to Databases Understanding XML Data Transfer • XML can be used for transferring data from client-side application to a server side application and vice versa. Server can host a database or an application. The data transfer can happen between applications or application and database. XML data transfer can happen in the following ways: • Map XML to databases • Query Languages • Map XML to databases • Mappings form the basis for data transfer between XML documents and databases. Following are the two types of mappings: • Table-Based Mapping • Query Languages ©NIIT Creating Data Centric Applications Using ADO.NET Slide 2 of 18
  • 3. Mapping XML to Databases Understanding XML Data Transfer (Contd.) • Table-Based Mapping • Table-based mapping is used for data transfer between an XML document and a relational database. You can also transfer data between relational databases by using the table-based mapping. • Object-Relational Mapping • In the object-relational mapping, the data in the XML document is organized in a hierarchical manner. This type of mapping is used by mostly XML-enabled relational databases such as SQL server. ©NIIT Creating Data Centric Applications Using ADO.NET Slide 3 of 18
  • 4. Mapping XML to Databases Understanding XML Data Transfer (Contd.) • Query Languages • Query languages are embedded in XML document and are used for data transfer between applications. • Template-Based Query Languages Construction • SQL-Based Query Languages • XML Query Languages ©NIIT Creating Data Centric Applications Using ADO.NET Slide 4 of 18
  • 5. Mapping XML to Databases Displaying Data from Multiple Tables using VC# • Consider an example. An application needs to be created to display a Windows Form. The form should display a combo box that comprises all Customer IDs. When a user selects a customer ID, the corresponding order IDs should be displayed in a list box. • To create an application for the above scenario, perform the following steps: • Create a Windows application • Add a combo box and list box to the form • Connect to the database • Create the data adapters and connections • Generate the Dataset that will contain the related data tables ©NIIT Creating Data Centric Applications Using ADO.NET Slide 5 of 18
  • 6. Mapping XML to Databases Displaying Data from Multiple Tables using VC#(Contd.) • Create the Relationship. • Fill the combo box with customer Ids. • Fill the dataset with data from the Customers and the Orders table. • Create an event handler to retrieve the order details for a selected customer. • Display the related records in the list box. • Follow easy to understand naming conventions for the system and processes. • Design the system in such a manner that it meets the immediate system requirements and can be modified later for enhanced features. • Test the modules. ©NIIT Creating Data Centric Applications Using ADO.NET Slide 6 of 18
  • 7. Mapping XML to Databases From the Expert’s Desk • This section provides: • Best practices on ADO.NET and Data Access Components • Tips and Tricks • FAQs on Data Binding and Data Reader. ©NIIT Creating Data Centric Applications Using ADO.NET Slide 7 of 18
  • 8. Mapping XML to Databases Best Practices Applying Best Practices to a Project • The best practices that you can follow in a project are: • Use the Appropriate Data-Access Object • Use SQL Data Types With SQL Server • Use Centralized Data-Access Functions • Use Centralized Data-Access Functions ©NIIT Creating Data Centric Applications Using ADO.NET Slide 8 of 18
  • 9. Mapping XML to Databases Tips and Tricks Establishing Quick Database Connection in .NET • While establishing connection to a database, you may find problems in creating the database connection string. Following sites provide connection strings that can be used in the applications • http://www.connectionstrings.com • http://www.able-consulting.com/ADO_Conn.htm ©NIIT Creating Data Centric Applications Using ADO.NET Slide 9 of 18
  • 10. Mapping XML to Databases FAQs • When using the SqlDataReader, how do you know the number of records that are found? The SqlDataReader provides means of reading a "forward-only" stream of rows from a SQL Server database. Therefore, the number of rows read from the database is not known until the last row is read. This is the same type of problem we had back in classic ADO where the Recordset's RecordCount was always -1 for a server-side, forward-only cursor. The solution in classic ADO was to use a static or keyset cursor. Or use a client-side cursor location, which always used a static cursor. However in ADO.NET 1.0, there is no such thing as a server-side, static or keyset cursor. There is only the server-side, forward-only DataReader. Or there is the client-side, static DataSet. •    ©NIIT Creating Data Centric Applications Using ADO.NET Slide 10 of 18
  • 11. Mapping XML to Databases FAQs(Contd.) You can work-around this issue by either Increment a counter while looping through all of the rows, or use two SELECT statements in your query. The first one returns the row count and the second one returns the actual rows. e.g. "SELECT COUNT(*) FROM myTableName; SELECT * FROM myTableName". Then you can use the NextResult method to move from the first to the second result set, or use a DataSet instead of the SqlDataReader. Then use the DataSet‘s Table Rows count. e.g. DataSet.Tables("Products").Rows.Count. • How can I bind a data grid to a relationship through code? To bind a data grid to a relationship through code, you set the DataSource property to the dataset that contains the relationship, and you set the DataMember property to the relationship. You must refer to the relationship through its parent table . ©NIIT Creating Data Centric Applications Using ADO.NET Slide 11 of 18
  • 12. Mapping XML to Databases FAQs(Contd.) For example, suppose you define a relationship named SalesInvoices that relates rows in a parent table named Sales to rows in a child table named Invoices. Then, if the relationship and tables are stored in a dataset named DsPayables2, you can bind a data grid named grdInvoices to the relationship using this code: grdInvoices.DataSource = DsPayables2 grdInvoices.DataMember = "Sales.SalesInvoices" • Why do I get a "Login failed" error message when I try to connect to a SQL Server database from a web application? This error typically occurs while using Windows NT Integrated security to connect to the database. This error occurs because ASP.NET runs as a separate Windows process with its own login name: ASPNET. ©NIIT Creating Data Centric Applications Using ADO.NET Slide 12 of 18
  • 13. Mapping XML to Databases FAQs(Contd.) When you try to access a SQL Server database from a web application, then, ASP.NET will try to use this login name to log in to SQL Server. For that to work, you first have to create a Windows user named ASPNET, and you have to create a SQL Server user account named ASPNET and grant it access to the database. A simpler solution is not to use Windows NT Integrated security. Instead, you can name the specific SQL Server account you want to use when you create the connection. If you’re using MSDE on your own system, for example, you can probably just use the default system administrator account, sa. ©NIIT Creating Data Centric Applications Using ADO.NET Slide 13 of 18
  • 14. Mapping XML to Databases Challenge ©NIIT Creating Data Centric Applications Using ADO.NET Slide 14 of 18
  • 15. Mapping XML to Databases Challenge (Contd.) • Across: • 13. Used for connecting to a database, retrieving data, storing the data dataset, reading the retrieved data, and updating the database. (11) • 134. Method of DataTable class to filter data(6) • 142. Language used to define the elements and attributes of XML documents(3) • Down: • 2. Object that creates a fixed customized view of given DataTable object(8) • 4. Provides the bridge between the DataSet object and the data source. (11) • 7. Type of binding, to display multiple values for a column from the dataset rows(7) • 9. ADO.NET uses the ___________ data architecture(12) ©NIIT Creating Data Centric Applications Using ADO.NET Slide 15 of 18
  • 16. Mapping XML to Databases Challenge (Contd.) • 12. Component that represents the column that uniquely identifies a row in a DataTable(10) • 13. A recordset in ADO is similar to a _________ in ADO.NET (7) • 22. Used to retrieve data from a data source in a read-only and forward-only mode(10) • 39. Method used to stop the connection with a data source(5) • 41. Represents a table in the DataTableCollection of a dataset(9) • 54. Dataset, which does not have any associated XML schema(7) • 56. Control, which displays data from multiple records as well as multiple columns. (8) • 59. Data command to enter data into a database(6) • 79. Fundamental format for data transfer in ADO.NET(3) ©NIIT Creating Data Centric Applications Using ADO.NET Slide 16 of 18
  • 17. Mapping XML to Databases Solution to Challenge ©NIIT Creating Data Centric Applications Using ADO.NET Slide 17 of 18
  • 18. Mapping XML to Databases Summary • XML can be used for transferring data from client-side application to a server side application and vice versa. Server can host a database or an application. • XML data transfer can happen in the following ways: • Map XML to databases • Query Languages • Query languages are embedded in XML document and are used for data transfer between applications. • You can display data from multiple tables using VC# • The best practices that you can follow in a project are: • Use the Appropriate Data-Access Object • Use SQL Data Types With SQL Server • Use Centralized Data-Access Functions • Use Centralized Data-Access Functions ©NIIT Creating Data Centric Applications Using ADO.NET Slide 18 of 18