我无法弄清楚为什么我的代码没有结果:
<Query Name="getClubPoints" RowName="Points">
<SQL>
<![CDATA[
SELECT FirstName, LastName, ClubPoints
FROM Customer
WHERE CustomerID = '78520'
]]>
</SQL>
</Query>
<PackageTransform>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:aspdnsf="urn:aspdnsf" exclude-result-prefixes="aspdnsf">
<xsl:output method="html" omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:if test="/root/System/CustomerIsRegistered='true'">
<!--Customer is registered-->
[<xsl:value-of select="/root/System/CustomerID" />] <xsl:value-of select="concat('Welcome, ',/root/System/CustomerFirstName)"/>!<br />
You have [<xsl:value-of select="ClubPoints" />] Club Points
</xsl:if>
</xsl:template>
</xsl:stylesheet>
</PackageTransform>
此用户(我)拥有284点积分。此外,一旦我完成这项工作,我如何用变量替换78520以获取当前登录用户的ID?
答案 0 :(得分:1)
这将检查运行时参数,并将SQL查询中的占位符“@customer”替换为当前客户的ID。另请参阅:http://manual.aspdotnetstorefront.com/p-157-xml-packages.aspx
<Query Name="getClubPoints" RowName="Points">
<SQL>
<![CDATA[
SELECT FirstName, LastName, ClubPoints
FROM Customer
WHERE CustomerID = @customer
]]>
</SQL>
<queryparam paramname="@customer" paramtype="runtime" requestparamname="CustomerID" sqlDataType="int" defvalue="0" validationpattern="" />
</Query>