XML and the SQL 2000 Server, Part 4: Introducing SqlXml 3.0 - Exploring the SqlXmlCommand Class
(Page 4 of 9 )
In order to effectively exchange data both ways between realtional and xml, it is necessary to understand the workings of the SqlXmlCommand class, especially the properties and methods that make this data access possible. In the previous picture a number of properties and methods were identified [red rectangles], and these will be explored in this section. Here follows a list of properties and methods of SqlXmlCommand Class.
Properties and Methods of SqlXmlCommand Class - TransactSQL Extensions:
- SqlXmlCommand's ExecuteStream Method
- SqlXmlCommand's RootTag Property
- SqlXmlCommand's NameSpace Property
- SqlXmlCommand's ExecuteToStream Method
- SqlXmlCommand's ExecuteXMLReader
- Stored Procedures:
- Using named Stored procedure in CommandText & ExecuteStream
- Templates/Template files:
- Using CommandType=Template and a CommandText with
Template String - Using CommandType=TemplateFile and referencing
a TemplateFile for CommandText
- Styling with XSLT:
- Using the BasePath and XSLPath properties.
SqlXmlCommand's ExecuteStream Method The SQLXMLCommand uses the connection described by the connection string and issues a ExecuteStream method. The Command is configured to return a XML Fragment by its CommandText property. Stream result is captured in the StreamReader and the read stream is sent to the textbox. The stream sent to textbox is shown in the picture following the code.
Reference System.IO and Microsoft.DATA.SqlXml.
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
Dim sxcmd As New SqlXmlCommand
("Integrated Security=SSPI;Packet Size=4096;Data Source=XPHTEK;
Tag with column collation when possible=False;Initial Catalog=pubs;
Use Procedure for Prepare=1;
Auto Translate= True;Persist SecurityInfo=False;
Provider='SQLOLEDB.1';Workstation ID=XPHTEK;Use Encryption for
Data=False")
sxcmd.CommandText = "select pub_id, price,
type,ytd_sales,titleauthor.title_id,au_ord from titles,
titleauthor where titleauthor.title_id= titles.title_id andprice>15
order by pub_id for xml auto"
'Memory stream is declared
Dim strmResults As MemoryStream
strmResults = sxcmd.ExecuteStream()
Response.Write(strmResults.Length)
Dim strmReader As New StreamReader(strmResults)
TextBox1.Text = strmReader.ReadToEnd
End If
End Sub
Next: SqlXmlCommand's RootTag Property >>
More MS SQL Server Articles
More By Jayaram Krishnaswamy