Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Daniel Abbitt 13 posts 33 karma points
    Jul 21, 2011 @ 10:43
    Daniel Abbitt
    0

    Multiple Instances of SQL Helper

    Hi All,

    Am new to the forum but have spent the last few weeks working with Umbraco. The site I'm building has a lot of background data stored in a MSSQL database, as such I've used the SQLHelper "add-on".

    The problem I'm facing is that I need to run two different stored procedures within the same XSLT. The reason for being in the same XSLT is that data from the first needs to be passed in as a parameter to the second. For whatever reason, when using the code below, I don't get anything displayed from the second SQLHelper.

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
    <xsl:stylesheet
      version="1.0"
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      xmlns:msxml="urn:schemas-microsoft-com:xslt"
      xmlns:SqlHelper="urn:SqlHelper"
      xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets SqlHelper">
      
    <xsl:output method="xml" omit-xml-declaration="yes"/>
    <xsl:param name="currentPage"/>
        
    <xsl:template match="/">
      
      <xsl:variable name="pEventID">
        <xsl:value-of select="umbraco.library:RequestQueryString('EventID')" />
      </xsl:variable>
      
      <xsl:variable name="defaultEventID">1</xsl:variable>
      
      <xsl:variable name="params">
      <sqlhelper>
        <commandtype>storedprocedure</commandtype>
        <commandtext><![CDATA[dbo.SessionList]]></commandtext>
        <parameter name="@pEventID">
          <xsl:choose>
            <xsl:when test="string-length($pEventID) &gt; 0">
              <xsl:value-of select="$pEventID" />
            </xsl:when>
            <xsl:otherwise>
              <xsl:value-of select="$defaultEventID" />
            </xsl:otherwise>
          </xsl:choose>
        </parameter>
        <connectionstring appkey="***"></connectionstring>
      </sqlhelper>
      </xsl:variable>
     
      
      <xsl:apply-templates select="SqlHelper:ExecuteDataset($params)/root" />
      
    </xsl:template>
      
      <xsl:template match="root">
        <div id="results">
            <xsl:apply-templates select="item" mode="row" />
        </div>
      </xsl:template>
          
          <xsl:template match="item" mode="row">
             <xsl:for-each select="./child::*">
               <xsl:if test="local-name() = 'SessionName'">
                 <br /><strong><xsl:value-of select="." /></strong><br />
               </xsl:if>
               
               <xsl:if test="local-name() = 'SessionID'">
                 <xsl:call-template name="subMain">
                   <xsl:with-param name="sessionID" select="." />
                 </xsl:call-template>
               </xsl:if>
              </xsl:for-each>
           </xsl:template>
    <!-- SUB TEMPLATES -->
        <xsl:template name="subMain">
      
          <xsl:param name="sessionID" />
      
          <xsl:variable name="params">
            <sqlhelper>
            <commandtype>storedprocedure</commandtype>
            <commandtext><![CDATA[dbo.RaceResults]]></commandtext>
            <parameter name="@pSessionID"><xsl:value-of select="$sessionID" /></parameter>
            <connectionstring appkey="fpaDbDSN"></connectionstring>
            </sqlhelper>
          </xsl:variable>
     
      
          <xsl:apply-templates select="SqlHelper:ExecuteDataset($params)/subRoot" />
      
        </xsl:template>
      
          <xsl:template match="subRoot">
            <div id="results">
                <xsl:apply-templates select="subItem" mode="row" />
            </div>
          </xsl:template>
          
          <xsl:template match="subItem" mode="row">
             <xsl:for-each select="./child::*">
               <xsl:value-of select="." /><br />
             </xsl:for-each>
          </xsl:template>
    </xsl:stylesheet>
Please Sign in or register to post replies

Write your reply to:

Draft