• Save
Ado.net session14
Upcoming SlideShare
Loading in...5
×
 

Ado.net session14

on

  • 646 views

 

Statistics

Views

Total Views
646
Slideshare-icon Views on SlideShare
622
Embed Views
24

Actions

Likes
0
Downloads
0
Comments
0

2 Embeds 24

http://niitcourseslides.blogspot.in 23
http://niitcourseslides.blogspot.com 1

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Introduce the students to the course by asking them what they know about forensics. Next, ask the students what they know about system forensics and why is it required in organizations dependent on IT. This could be a brief discussion of about 5 minutes. Lead the discussion to the objectives of this chapter.
  • Introduce the students to the course by asking them what they know about forensics. Next, ask the students what they know about system forensics and why is it required in organizations dependent on IT. This could be a brief discussion of about 5 minutes. Lead the discussion to the objectives of this chapter.
  • Introduce the students to the course by asking them what they know about forensics. Next, ask the students what they know about system forensics and why is it required in organizations dependent on IT. This could be a brief discussion of about 5 minutes. Lead the discussion to the objectives of this chapter.
  • Introduce the students to the course by asking them what they know about forensics. Next, ask the students what they know about system forensics and why is it required in organizations dependent on IT. This could be a brief discussion of about 5 minutes. Lead the discussion to the objectives of this chapter.
  • Introduce the students to the course by asking them what they know about forensics. Next, ask the students what they know about system forensics and why is it required in organizations dependent on IT. This could be a brief discussion of about 5 minutes. Lead the discussion to the objectives of this chapter.
  • Introduce the students to the course by asking them what they know about forensics. Next, ask the students what they know about system forensics and why is it required in organizations dependent on IT. This could be a brief discussion of about 5 minutes. Lead the discussion to the objectives of this chapter.
  • Introduce the students to the course by asking them what they know about forensics. Next, ask the students what they know about system forensics and why is it required in organizations dependent on IT. This could be a brief discussion of about 5 minutes. Lead the discussion to the objectives of this chapter.
  • Introduce the students to the course by asking them what they know about forensics. Next, ask the students what they know about system forensics and why is it required in organizations dependent on IT. This could be a brief discussion of about 5 minutes. Lead the discussion to the objectives of this chapter.
  • Introduce the students to the course by asking them what they know about forensics. Next, ask the students what they know about system forensics and why is it required in organizations dependent on IT. This could be a brief discussion of about 5 minutes. Lead the discussion to the objectives of this chapter.
  • Introduce the students to the course by asking them what they know about forensics. Next, ask the students what they know about system forensics and why is it required in organizations dependent on IT. This could be a brief discussion of about 5 minutes. Lead the discussion to the objectives of this chapter.
  • Introduce the students to the course by asking them what they know about forensics. Next, ask the students what they know about system forensics and why is it required in organizations dependent on IT. This could be a brief discussion of about 5 minutes. Lead the discussion to the objectives of this chapter.
  • Introduce the students to the course by asking them what they know about forensics. Next, ask the students what they know about system forensics and why is it required in organizations dependent on IT. This could be a brief discussion of about 5 minutes. Lead the discussion to the objectives of this chapter.
  • Introduce the students to the course by asking them what they know about forensics. Next, ask the students what they know about system forensics and why is it required in organizations dependent on IT. This could be a brief discussion of about 5 minutes. Lead the discussion to the objectives of this chapter.
  • Introduce the students to the course by asking them what they know about forensics. Next, ask the students what they know about system forensics and why is it required in organizations dependent on IT. This could be a brief discussion of about 5 minutes. Lead the discussion to the objectives of this chapter.
  • Introduce the students to the course by asking them what they know about forensics. Next, ask the students what they know about system forensics and why is it required in organizations dependent on IT. This could be a brief discussion of about 5 minutes. Lead the discussion to the objectives of this chapter.
  • Introduce the students to the course by asking them what they know about forensics. Next, ask the students what they know about system forensics and why is it required in organizations dependent on IT. This could be a brief discussion of about 5 minutes. Lead the discussion to the objectives of this chapter.
  • Introduce the students to the course by asking them what they know about forensics. Next, ask the students what they know about system forensics and why is it required in organizations dependent on IT. This could be a brief discussion of about 5 minutes. Lead the discussion to the objectives of this chapter.
  • Introduce the students to the course by asking them what they know about forensics. Next, ask the students what they know about system forensics and why is it required in organizations dependent on IT. This could be a brief discussion of about 5 minutes. Lead the discussion to the objectives of this chapter.

Ado.net session14 Ado.net session14 Presentation Transcript

  • Developing Database Applications Using ADO.NET and XMLObjectives In this session, you will learn to: Manage XML data in SQL Server 2005 Ver. 1.0 Session 14 Slide 1 of 18
  • Developing Database Applications Using ADO.NET and XMLProcessing XML Data in SQL Server 2005 • SQL Server 2005 supports native XML data. • There are various benefits of storing XML data in SQL Server 2005. • XML data is stored in SQL Server 2005 in the form on the xml data type. Ver. 1.0 Session 14 Slide 2 of 18
  • Developing Database Applications Using ADO.NET and XMLAccessing XML Data from SQL Server • SqlXml class enables you to work with the xml data type. • SqlXml class is defined in the System.Data.SqlTypes namespace. • Consider the following SQL queries: CREATE TABLE Students(Marks xml) INSERT Students VALUES(<Marks><English>85</English><Math> 100</Math></Marks>) INSERT Students VALUES(<Marks><English>83</English><Math> 96</Math></Marks>) Ver. 1.0 Session 14 Slide 3 of 18
  • Developing Database Applications Using ADO.NET and XMLAccessing XML Data from SQL Server (Contd.) • You can retrieve the records stored in Students and display them in a DataGrid control using the SqlXml class and the GetSqlXml() method. • The GetSqlXml() method retrieves the instance of the SqlXml class. Ver. 1.0 Session 14 Slide 4 of 18
  • Developing Database Applications Using ADO.NET and XMLAccessing XML Data from SQL Server (Contd.) The following code snippet performs this task: using (SqlCommand cmd = conn.CreateCommand()) { cmd.CommandText = "SELECT * FROM Students"; using (SqlDataReader rdr = cmd.ExecuteReader()) { while (rdr.Read()) Reads each row. { SqlXml student = Retrieve the instance of the rdr.GetSqlXml(0); SqlXml class. Ver. 1.0 Session 14 Slide 5 of 18
  • Developing Database Applications Using ADO.NET and XMLAccessing XML Data from SQL Server (Contd.) if (!student.IsNull) As long as the SqlXml object is not null, the XML data is { read into the Dataset object. Each SqlXml object that is ds.ReadXml(student.Create read into the DataSet object Reader()); appends to the existing XML data. Display the contents of the dataGrid1.DataSource = ds; dataset in the DataGrid. Ver. 1.0 Session 14 Slide 6 of 18
  • Developing Database Applications Using ADO.NET and XMLAccessing XML Data from SQL Server (Contd.) The preceding code gives the following output. Ver. 1.0 Session 14 Slide 7 of 18
  • Developing Database Applications Using ADO.NET and XMLUpdating XML Data to SQL Server • To update SQL Server with XML data, you need to first fill a dataset with XML and then update the database with the dataset. • To fill a dataset with data from XML, you need to use the ReadXml() method. This method is defined in the DataSet class. • The ReadXml() method reads from a file or an XmlReader and takes as arguments the source of the XML file and an optional XmlReadMode argument. Ver. 1.0 Session 14 Slide 8 of 18
  • Developing Database Applications Using ADO.NET and XMLUpdating XML Data to SQL Server (Contd.) • XmlReadMode has the following options: Auto ReadSchema IgnoreSchema InferSchema DiffGram Ver. 1.0 Session 14 Slide 9 of 18
  • Developing Database Applications Using ADO.NET and XMLUpdating XML Data to SQL Server (Contd.) • XmlReadMode has the following options:  Auto It examines the XML data and  ReadSchema selects the appropriate option.  IgnoreSchema  InferSchema  DiffGram Ver. 1.0 Session 14 Slide 10 of 18
  • Developing Database Applications Using ADO.NET and XMLUpdating XML Data to SQL Server (Contd.) • XmlReadMode has the following options:  Auto  ReadSchema It reads an inline schema and loads the data and the schema.  IgnoreSchema  InferSchema  DiffGram Ver. 1.0 Session 14 Slide 11 of 18
  • Developing Database Applications Using ADO.NET and XMLUpdating XML Data to SQL Server (Contd.) • XmlReadMode has the following options:  Auto  ReadSchema  IgnoreSchema It ignores inline schemas and loads  InferSchema the XML data into the existing dataset schema.  DiffGram Ver. 1.0 Session 14 Slide 12 of 18
  • Developing Database Applications Using ADO.NET and XMLUpdating XML Data to SQL Server (Contd.) • XmlReadMode has the following options:  Auto  ReadSchema  IgnoreSchema  InferSchema It ignores any inline schema and infers the schema according to the  DiffGram structure of the XML data. Ver. 1.0 Session 14 Slide 13 of 18
  • Developing Database Applications Using ADO.NET and XMLUpdating XML Data to SQL Server (Contd.) • XmlReadMode has the following options:  Auto  ReadSchema  IgnoreSchema  InferSchema It reads a DiffGram and loads the  DiffGram data into the current schema. Ver. 1.0 Session 14 Slide 14 of 18
  • Developing Database Applications Using ADO.NET and XMLUpdating XML Data to SQL Server (Contd.) • To load dataset schema information from an XML document, use either the ReadXmlSchema() or the InferXmlSchema() methods of the DataSet. • ReadXmlSchema() helps load or infer DataSet schema information from the document containing XML Schema definition language (XSD) schema, or an XML document with inline XML Schema. • InferXmlSchema() helps infer the schema from the XML document while ignoring certain XML namespaces that are specified. Ver. 1.0 Session 14 Slide 15 of 18
  • Developing Database Applications Using ADO.NET and XMLDemo: Working with XML Data Problem Statement: The details of internal and external candidates, which are maintained by the head office of Tebisco, need to be sent to the various branch offices in an XML format. Create an application that will perform this task. After data is received by the various branch offices, the data needs to be merged into a new XML file. Then, the data from this file should be displayed on a Windows form. Create the required two applications. Ver. 1.0 Session 14 Slide 16 of 18
  • Developing Database Applications Using ADO.NET and XMLExercises Exercise 1: The address details of the employees of Tebisco are stored in a table, Address_Details, in an XML format. An application needs to be created that will allow a user to view this data in a form. Perform the required task. Ver. 1.0 Session 14 Slide 17 of 18
  • Developing Database Applications Using ADO.NET and XMLSummary In this session, you learned that:  You can access instances of the SqlXml class by using the DataReader object’s GetSqlXml() method.  To fill a dataset with data from XML, you need to use the ReadXml() method.  To load dataset schema information from an XML document, you can use either the ReadXmlSchema() or the InferXmlSchema(), methods of the dataset. Ver. 1.0 Session 14 Slide 18 of 18