Hi There,<BR><BR>I&#039;m trying to do an XML / XLS transform but am having trouble retrieving my data. The trouble seems to be with the parameter - if I hard code the id in the template SQL, everything works, but when I use .CreateParameter to set the @ID value then i get an exception:<BR><BR>"Microsoft.Data.SqlXml.SqlXmlExc eption: Exception from HRESULT: 0x80040E21. ---&#062; System.Runtime.InteropServices.COMException (0x80040E21): Exception from HRESULT: 0x80040E21. at Microsoft.Data.SqlXml.Common.ISQLXMLCommandManaged Interface.ExecuteToOutputStream()" <BR><BR>The code looks like this:<BR><BR> Dim oTransform As New Xsl.XslTransform<BR> Dim DataURL As String<BR><BR> Try<BR> &#039;Set response properties<BR> With Response<BR> .ContentType = "text/html"<BR> &#039;Get the data as XML<BR> Dim ID As Integer<BR> ID = Integer.Parse(Request.QueryString("ID"))<BR> Dim oCmd As New SqlXmlCommand(CONN_STRING)<BR> oCmd.CommandType = SqlXmlCommandType.TemplateFile<BR> oCmd.CommandText = Server.MapPath("./templates/Template.xml")<BR> Dim oParam As SqlXmlParameter = oCmd.CreateParameter()<BR> oParam.Name = "@ID"<BR> oParam.Value = ID<BR><BR> &#039;Transform<BR> oTransform.Load(Server.MapPath("./templates/p7.xsl"))<BR> Dim xDoc As New XPathDocument(oCmd.ExecuteXmlReader, XmlSpace.Default)<BR><BR> Dim xNav As XPathNavigator = xDoc.CreateNavigator()<BR> oTransform.Transform(xDoc, Nothing, Response.OutputStream, Nothing)<BR> .Flush()<BR> End With<BR><BR> Catch ex As System.Xml.Xsl.XsltException<BR> Throw New Exception("Doh", ex)<BR> Catch ex As Exception<BR> Throw New Exception("Doh", ex)<BR> Finally<BR> oTransform = Nothing<BR> End Try<BR><BR>And the Template.xml file looks like:<BR><BR>&#060;Plan xmlns:sql="urn:schemas-microsoft-com:xml-sql"&#062;<BR> &#060;sql:query&#062;<BR> SELECT Business.*, <BR> FROM Business <BR> WHERE (Business.BusinessID = @ID)<BR> FOR XML AUTO, ELEMENTS<BR> &#060;/sql:query&#062;<BR>&#060;/Plan&#062;<BR><BR>The only thing the MS documentation has to say is:<BR><BR>"Note If you pass a parameter to a template, the parameter name must begin with &#039;@&#039; (for example, p.Name="@EmployeeID", where p is a SqlXmlParameter object)."<BR><BR>which doesn&#039;t help much as there isn&#039;t an example.<BR><BR>Any help would be greatly appreciated.<BR><BR>If anyone has successfully passed a parameter to a query like this an example would be wonderful!<BR><BR>Cheers,<BR><BR>Padgett Rowell<BR><BR>