.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

How to declare variable and assign value in xslt

Posted By:      Posted Date: September 08, 2010    Points: 0   Category :ASP.Net
Hi, I am writing xslt to create HTML by using input xml data. The input XML looks like this ID Name  Description 1 Name1 Description Something1 Name1 Description another text2 Name2 Some text2 Name2 Some text22 Name2 Some text2 Here Id is primary, where Name is unique as per ID. I want to show the output the following way Name1   * Description Something   * Description another textName2   * Some text   * Some text2   * Some text2 So I want to declare a variable in XSLT and make a loop in records and store the previous record ID. IF the previous record id is same, then no need to show the name. But when I declare in the following xslt, I am getting 'The variable or parameter 'xxx' was dublicated within the same scope' error<xsl:output method ="html" media-type="text/html" encoding="iso-8859-1" /> <xsl:template match="Details"> <xsl:variable name="counter" select="0"/> <xsl:for-each select="XMLParentNode/XMLDetailNode/XMLSubDetailNode"> <xsl:if test="$counter = 1"> <p> <b style='text-color:red;'> <xsl:value-of select="NAME" disable-output-

View Complete Post

More Related Resource Links

Must Declare a Scalar Variable @ActName

It is a stored procedure and I am trying to qualify O.FullName using a parameter but I am getting error message "Must Declare a Scalar Vaiable @ActName" Not sure why No idea what is wrong on this. The parameter is correct as @ActName SELECT A.AccountID, A.AccountGID, AT.Name AS Type, M.MarketSegmentID, L.LeadSourceGID, O.EmployeeID, O.FullName AS Owner, CASE WHEN Adr.City IS NULL OR Adr.City = ' ' THEN 'BLANK CITY' ELSE Adr.City END AS City, CASE WHEN Adr.Country IS NULL OR Adr.Country = ' ' THEN 'BLANK COUNTRY' ELSE Adr.Country END AS Country, CASE WHEN Adr.StateProvince IS NULL OR Adr.StateProvince = ' ' THEN 'BLANK STATE' ELSE Adr.StateProvince END AS State, CASE WHEN Adr.AddressLine1 IS NULL OR Adr.AddressLine1 = ' ' THEN 'BLANK ADDRESS' ELSE Adr.AddressLine1 END AS Address1, CASE WHEN Adr.Postal IS NULL OR Adr.Postal = ' ' THEN 'BLANK POSTAL' ELSE Adr.Postal END AS Postcode, CASE WHEN A.Name IS NULL OR A.Name = ' ' THEN 'BLANK ACCOUNT NAME' ELSE A.Name END AS ActName, CASE WHEN A.PhoneNumber IS NULL OR A.PhoneNumber = ' ' THEN 'BLANK PHONE #' ELSE A.PhoneNumber END AS Phone, CASE WHEN SIC.Name IS NULL OR SIC.Name = ' ' THEN 'BLANK SIC CODE' ELSE SIC.Name END AS SIC, CASE WHEN M.Name IS NULL OR M.Name = ' ' THEN 'BLANK MKT SEG' ELSE M.Name END AS MktSeg, CASE WHEN A

Must Declare Variable @tableName Error ?

create Procedure dummy ( @tablename nvarchar(20) ) AS Begin select ID,employeename from @tablename End I dont know why SqlServer is not able to search a table name so thought of getting some help from sql Gurus . Any help would highly be appreciated . Thanks .Rajkumar Yelugu

Must declare the scalar variable "@NieuwsID".

Hallo, I get the error message:  Must declare the scalar variable "@NieuwsID". Can anybody help? <%@ Page Title="" Language="VB" MasterPageFile="~/Nieuws/MasterPageNieuws.master" AutoEventWireup="false" CodeFile="Default.aspx.vb" Inherits="Nieuws_Default" %> <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"> <link href="../Inloggen.js" type="text/javascript" /> <script type="text/javascript"> function toonPopUp() { var popUpPanel = document.getElementById('popUpPanel'); popUpPanel.style.display = 'block'; } function verbergenPopUp() { var popUpPanel = document.getElementById('popUpPanel'); popUpPanel.style.display = 'none'; } </script> <style type="text/css"> #popUpPanel { position: absolute; width: 200px; height: 200px; top: 80px; left: 400px; display: none; border: medium #2B8ED6 solid; padding: 5px; background-color: #FFFFFF; color: #333333; vertical-align: middle; } #xlogon { border-style:none; font-family: Verdana; font-size:medium; color: #2B8ED6; background-color: Transparent; } #logtekst { text-align:left; top: 20px; width: 190px; } </style> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="C

Warning WithEvents variable, how do i declare shadow?

I get this warning , how do i overcome it. I have a grid veiw on a form with one of my rows  called Location.                                                        thanks rob Warning 1 WithEvents variable 'Location' conflicts with property 'Location' in the base class 'Form' and should be declared 'Shadows'. rh

How to declare a table variable in SSIS and then insert rows into it

Hello everyone,   I'll try to explain my problem as clearly as I can: 1)I have an Execute SQL Task that's inside a Foreach Loop Container. 2)Inside the Execute SQL Task, I have an int OUTPUT column. 3)With each iteration, I need to insert the data from the INT output colum into a table variable. 4)After the Foreach Loop finishes the iterations, I need to use the table variable to create a report based on the data inside.   My question is the following: How can I declare a table variable so that I can do all of the above?   Thank you, CostinP

Problem setting variable/param in XSLT for XML control in .NET 4.0

I am using an XML control in VS2010 with .NET 4.0.I am trying to sort XML data into a table. I have a drop list with the sort key, and a button that is supposed to display the table with a new sort.Here is the code the button calls:</p><p></p><p style="text-align: left;" mce_style="text-align: left;"><font class="Apple-style-span" face="Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace"><span class="Apple-style-span" style="border-collapse: collapse; line-height: 13px;" mce_style="border-collapse: collapse; line-height: 13px;" mce_fixed="1"></span></font></p><p><font class="Apple-style-span" face="Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace"></font></p><p><font class="Apple-style-span" face="Consolas, 'Bitstream Vera Sans Mono', 'Courier New', Courier, monospace"><div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;" id="_mcePaste">private void PopulateXML( Xml MyXML)</div> <div style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: h

How to prevent special character encoding when using xslt value in javascript variable

Hi, I've created a dataview and inserting a little bit of javascript. I need to store one of the xslt values into a javascript variable. The problem is that when I get the value into my javascript variable, it is already encoding special characters . for example, instead of "<", I get "&lt;" Am I doing something inaccurate here? I even tried using the javascript unescape() function, but that didn't work. would you be able to advise how to get the xslt value into a javascript variable as it is without having the original data changed? <xsl:template ... ... <SCRIPT type="text/javaScript"> <![CDATA[ ...     var myData = ']]><xsl:value-of select="@sampleData" disable-output-escaping="yes"/><![CDATA['  ;  ... ]]> </SCRIPT> Pman http://www.pmansLab.com/

XSLT Variable value into javascript

I want to redirect the page to a particular page on the basis of current logged in user's SharePoint group from a SharePoint .aspx child page. How can id do so? Please Let Me Know.

SQL Reporting Services 2005: Must declare scalar variable

I have a report that calls a stored procedure that builds a temp table and then runs a select that joins on that temp table. The only parameter I have is @Name, an optional parameter that can be filled or NULL.   I keep getting the error "An error has occurred during local report processing. An error has occurred during report processing. Query execution failed for data set. Must declare the scalar variable "@Name".   I have checked to make sure this parameter is connected to the dataset by looking at the parameter tab. I've searched on posts but haven't seen an answer. Does anyone have any idea what this could be about and how to fix it?

Gridview control Delete error -- Must declare the scalar variable "@GradeID"

 Hi All,Pardon me if this seems redundant. I have searched the archives and found many references to this type of error. Most (all?) boil down to a mismatch between the token for the databound field and the sql parameter. I have stared at this code for a long time and can see nothing wrong with it. In fact, it is so simple that I started over from scratch using only the designer (ie I wrote no code), so I don't see how it possible to have a name mismatch. I would very much appreciate any help figuring out what is the problem here. Thank you very much in advance.-Roger   Server Error in '/ssp/inet220a06' Application. Must declare the scalar variable "@GradeID". Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details: System.Data.SqlClient.SqlException: Must declare the scalar variable "@GradeID". Source Error: An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

What type variable can I use to assign a possible Null or a string to?



I am converting a VB6 app to VB2008 and are having problems with replacing Variant variables.

I used Variant in cases where the data might be string or Null.

Is there a way I could check for Null and just set the string to zero lenght?

Any help would be appreciated.



How to declare variable in SSRS 2008 in Dataset


Hi All,

I have to write query in which i have to declare variable ,i dont want to use SP ,i tried to write in DATASET only.


The query which runs fine in Query window in SQL as below



declare @a int

Set @a=(select count(*) from roles where rolename='browser')

select @a

but when i run the same query in SSRS Dataset in throws error


"An error occured while the query design method was being saved. ORA-06550; line 1,column 9:PLS-00103: Encountered the symbol "@A" when expecting one of the following:

Being function package pragma procedure subtype type use <an identifier><a double -quoted delimited-identifier>form current cursor

Kindly Suggest how to declare variable in SSRS dataset







Msg 137, Level 15, State 2, Procedure AddCMEXperience, Line 49 Must declare the scalar variable "@Re


Hi folks, can someone please help me with this error?

Msg 102, Level 15, State 1, Procedure AddCMEXperience, Line 15
Incorrect syntax near ','.

Msg 137, Level 15, State 2, Procedure AddCMEXperience, Line 49
Must declare the scalar variable "@ReasonLeft".

Here is the Stored Procedure that is in question here

USE [ResponsedDatabase]
/****** Object:  StoredProcedure [dbo].[AddNewEmployer]    Script Date: 10/03/2010 14:24:51 ******/

CREATE PROCEDURE [dbo].[AddCMEXperience]
    @MemberID bigint,
    @EmployerID bigint,
    @DateStarted smalldatetime,
    @IsContinuing bit,
    @DateLeft smalldatetime,
    @PositionStarted nvarchar(50),
    @PositionLeft nvarchar(50),
    @StartingSalary nvarchar(20),
    @EndingSalary nvarchar(20),
    @TimeWorked float,
    @JobResponsibilities text,
    @ReasonLeft, nvarchar(200)


INSERT CMExperience

Declare and Use Variable



I have the following:

use master

exec sp_configure 'filestream access level', 2;

declare @Database nvarchar(40) = 'MyDB';
declare @Login nvarchar(40) = 'MyDBLogin';
declare @Password nvarchar(40) = 'MyPass';
declare @Role nvarchar(40) = 'MyRole';

if exists (select * from sys.server_principals where name = @Database)
drop login @Login

I get the following error on "drop login @Login":

Incorrect syntax near '@Login'.

What am

Must declare the scalar variable "@UserId


I am receiving this error in my application :" Must declare the scalar variable "@UserId"."


Here is the code that generate the error:


<asp:SqlDataSource ID="categoriesDataSource"<

Error: Must declare the scalar variable - HELP!!


I have a textbox on my web page that allows the user to search for customers.  When they click on search, the following code below is running.  I am receiving the error message when trying to populate the data table.  Error Message says: Must declare the scalar variable "@SearchParms".

I tried re-testing and hardcoding '%oh%' in place of the @SearchParms and the query worked perfectly and posted the data back correctly.  I am racking my brain trying to figure out what I am doing wrong.  Can anyone help??

 string CustSearch = "'%'" + txtCustSearch.Text + "'%'";
        //Define query
        string sql = "SELECT CustomerID, FirstName, LastName, Email, City, State, Phone FROM dbo.Customer WHERE (FirstName LIKE '@SearchParms') OR (LastName LIKE '@SearchParms') OR (City LIKE '@SearchParms') OR (State LIKE '@SearchParms') ORDER BY LastName, FirstName";

        //Declare the Command
        SqlCommand cmd = new SqlCommand(sql, Conn);

        //Add the parameters needed for the SQL query

Assign guid to variable in control flow


How do I assign a script task generated GUID to an ssis variable and then pass it to sql server via a stored proc? I've only been able to find info on how to do it in a data flow task (derived column)

There doesn't seem to be a GUID type in the Data Type drop down in the Variables tab

I get the following error whether I create the variable as an object or string & setting the data type of the variable to either object,guid or string in the parameter mapping tab of the execute sql task don't do much either

Error: 0xC002F210 at Log Fail, Execute SQL Task: Executing the query "EXEC dbo.spLogGenericExtractControlOnComplete
    ..." failed with the following error: "Conversion failed when converting from a character string to uniqueidentifier.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.
Task failed: Log Fail


What magic combination of settings do I have to use to make it work?

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend