ADO Command - .Properties("XSL").Value = XSL_FILE

T

Terry Aney

I used to have the following code in VB/ADO when using a
FOR XML clause in SQL Server. Is there a .Net/ADO.Net
counterpart?

' Set strm = New ADODB.Stream
' With strm
' .LineSeparator = adCRLF
' .Mode = adModeRead
' .Type = adTypeText
' .Open
' End With
'

' Set cmd = New ADODB.Command
' With cmd
' .CommandType = adCmdText
' .CommandText = sQry
'
' Set cn = GetConnection(,
m_sServerName, "SynergySystem", m_sSQLLogin,
m_sSQLPassword)
' Set .ActiveConnection = cn
' .Properties("Output Stream").Value = strm
' .Properties("Output Encoding").Value = "UTF-
16" ' "Unicode"
' .Properties("XML Root").Value = "JobQueue"
' If ForDisplay Then
' .Properties("XSL").Value = App.Path
& "\SynergyQueue.xsl"
' End If
' Call .Execute(, , adExecuteStream)
' Call CloseConnection(cn)
' End With
 
D

David Sceppa

Terry,

Your best bet would be to use the SQL XML classes. The
SqlXmlCommand object exposes the properties (RootTag, XslPath,
SchemaPath, OutputEncoding, etc.) and methods (ExecuteXmlReader,
ExecuteStream, ExecuteToStream) you're looking for.

To learn more about these classes, see the SQL XML
information on the MSDN web site at msdn.microsoft.com/sqlxml.
From there, you'll find links to documentation on the object
model and links to install the current release of SQL XML (SQLXML
3.0 SP2).

Your code would look something like this:

Dim strConn, strSQL As String
strConn = "Provider=SQLOLEDB;Data Source=(local)\NetSDK;" & _
"Initial Catalog=Northwind;Trusted_Connection=Yes;"
strSQL = "..."
Dim cmd As New SqlXmlCommand(strConn)
With cmd
.CommandText = strSQL
.RootTag = "JobQueue"
.OutputEncoding = "UTF-16"
.XslPath = App.Path & "\SynergyQueue.xsl"
.ExecuteToStream(MyStream)
End With

I hope this information proves helpful.

David Sceppa
Microsoft
This posting is provided "AS IS" with no warranties,
and confers no rights. You assume all risk for your use.
© 2003 Microsoft Corporation. All rights reserved.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top