P
PL
According to the documentation I'm supposed to be able to use any classes in the
..NET framework inside a msxml:script block if I use a fully qualified path.
I'm trying to test the XSL sheet below with ASP.NET and all I'm
getting is:
error CS0234: The type or namespace name 'Data' does not exist in
the class or namespace 'System' (are you missing an assembly reference?)
Could someone explain how you reference these classes from inside a msxml:script
block, I cannot find anything but really simple examples that do not reference any other
classes than the default.
<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:user="http://mycompany.com/mynamespace"
version="1.0">
<!-- For this example use the book.xml example -->
<msxsl:script language="C#" implements-prefix="user">
<![CDATA[
string execSQL(string sql)
{
try{
System.Data.SqlClient.SqlConnection objconn = new System.Data.SqlClient.SqlConnection("connection-string-here");
objconn.Open();
System.Data.SqlClient.SqlCommand objcommand = new System.Data.SqlClient.SqlCommand(sql,objconn);
return((string)objcommand.ExecuteScalar());
}
catch(System.Exception ee)
{
return(ee.ToString());
}
finally
{
objconn.Close();
}
}
]]>
</msxsl:script>
<xsl:template match="/">
<xsl:value-of select="user:execSQL('SELECT TOP 1 Name FROM Table1')"/>
</xsl:template>
</xsl:stylesheet>
..NET framework inside a msxml:script block if I use a fully qualified path.
I'm trying to test the XSL sheet below with ASP.NET and all I'm
getting is:
error CS0234: The type or namespace name 'Data' does not exist in
the class or namespace 'System' (are you missing an assembly reference?)
Could someone explain how you reference these classes from inside a msxml:script
block, I cannot find anything but really simple examples that do not reference any other
classes than the default.
<?xml version="1.0" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxsl="urn:schemas-microsoft-com:xslt"
xmlns:user="http://mycompany.com/mynamespace"
version="1.0">
<!-- For this example use the book.xml example -->
<msxsl:script language="C#" implements-prefix="user">
<![CDATA[
string execSQL(string sql)
{
try{
System.Data.SqlClient.SqlConnection objconn = new System.Data.SqlClient.SqlConnection("connection-string-here");
objconn.Open();
System.Data.SqlClient.SqlCommand objcommand = new System.Data.SqlClient.SqlCommand(sql,objconn);
return((string)objcommand.ExecuteScalar());
}
catch(System.Exception ee)
{
return(ee.ToString());
}
finally
{
objconn.Close();
}
}
]]>
</msxsl:script>
<xsl:template match="/">
<xsl:value-of select="user:execSQL('SELECT TOP 1 Name FROM Table1')"/>
</xsl:template>
</xsl:stylesheet>