MS SQL Server
  Home arrow MS SQL Server arrow Page 2 - XML and the SQL 2000 Server, Part 4: Intro...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
MS SQL SERVER

XML and the SQL 2000 Server, Part 4: Introducing SqlXml 3.0
By: Jayaram Krishnaswamy
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 2 stars2 stars2 stars2 stars2 stars / 11
    2005-06-01

    Table of Contents:
  • XML and the SQL 2000 Server, Part 4: Introducing SqlXml 3.0
  • XML data using Dataset
  • Enter SQLXML 3.0
  • Exploring the SqlXmlCommand Class
  • SqlXmlCommand's RootTag Property
  • SqlXmlCommand's NameSpace Property
  • SqlXmlCommand's ExecuteXMLReader
  • Using CommandType Template
  • Using the BasePath and XSLPath properties

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    XML and the SQL 2000 Server, Part 4: Introducing SqlXml 3.0 - XML data using Dataset


    (Page 2 of 9 )

    The dataset set is a very important class as it represents the dual nature of data, its existence in a relational format(table) and its internal representation as XML. It provides a disconnected view of the data on the server. The following picture shows the partial view of Dataset class as seen in the ClassViewer.

    So how does the data retrieved from server in XML? A SQLConnection is made to the server(as in the previous case), a SQLCommand is created to grab the XML fragment using the TSQL extension clause(as in the previous case), a SQLDataAdapter uses this command as its argument. The SQLDataAdapter's fill method, populates the DataSet's table. The Dataset calls its WriteXML method to the MemoryStream. The stream from this StreamReader can then be displayed.

    An ASP.NET web application is started and a SqlConnection1 is added to the web form and then a SqlCommand1 control added and configured as mentioned in the previous case. Additionally, a Textbox control is added to the web form to receieve the stream data. In the Page_load event, the following code is written(remember to include imports for Systeem.IO and System. Xml).

    Private Sub Page_Load(ByVal sender As System.Object, ByVal _
    e As System.EventArgs) Handles MyBase.Load
    'Put user code to initialize the page here
    If Not IsPostBack Then
    SqlConnection1.Open()'dropped,configured control
    Dim cmd As New SqlClient.SqlCommand
    cmd = SqlCommand1'dropped, configured control
    Dim da As New SqlClient.SqlDataAdapter(cmd)
    Dim ds As New DataSet("Titles")
    da.Fill(ds, "Publishers")
    SqlConnection1.Close()
    'Write the DataSet as XML to a Stream        
    Dim strm As New MemoryStream
    ds.WriteXml(strm, XmlWriteMode.IgnoreSchema)
    strm.Position = 0
    Dim strmR As New StreamReader(strm)
    ''Display the contents of the stream 
    TextBox1.Text = strmR.ReadToEnd
    strm.Close()
    End If
    End Sub
    

    The result of building this project and browsing the web form in IE yields the following,

    More MS SQL Server Articles
    More By Jayaram Krishnaswamy


     

    MS SQL SERVER ARTICLES

    - Completing the Introduction to Transact-SQL
    - A Brief Introduction to Transact-SQL
    - Lookups and Blocking Bad Data
    - Field Validation Rules for Blocking Bad Data
    - Using Masks to Block Bad Data
    - Blocking Bad Data
    - Using @@ROWCOUNT and TABLE Variables for Dat...
    - How to Use Variables, IF and CASE in Databas...
    - Creating Important Aspects of Notification S...
    - Working wth Variables in Database Interactio...
    - Delving Deeper into Notification Services
    - Notification Services
    - Building a Multi-table Report with SQL 2005 ...
    - A Secure Way of Building Connection Strings
    - Transferring a Database Using the SSIS Desig...





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT