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


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

' 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,
' 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

David Sceppa


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
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"
End With

I hope this information proves helpful.

David Sceppa
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