0

我无法弄清楚为什么我没有得到这段代码的结果:

<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?

4

1 回答 1

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>
于 2014-09-11T15:41:31.900 回答