.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

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

Posted By:      Posted Date: September 18, 2010    Points: 0   Category :ASP.Net
 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.

View Complete Post

More Related Resource Links

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

Adding Dynamic Rows in ASP.NET GridView Control with TextBoxes and with Delete functionality

In my previous examples, I have demonstrated on how to add dynamic rows in GridView control with TextBoxes and how to save the values into the database. Now, seems that most of the developers are asking if how to add a delete functionality with it. So in this example, I'm going to show on how to delete a certain row in the dynamic GridView with TextBoxes.

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

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?

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

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

Must declare the scalar variable

Hello! I have a aspx page in which I have a Gidview populated by a sqlDataSouce.
This is my code:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="CostEmployee1.aspx.vb" Inherits="RecursosHumanos_CostEmployee1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<form id="form1" runat="server">
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False"

Nested GridView Control returns "Object variable or With block variable not set" when outer GridView


Nested GridView Control returns "Object variable or With block variable not set" when outer GridView returns rows.

The Nested GridView Control works as long as the outer GridView returns rows, the following code works:


Protected Sub GridViewReport_RowCreated(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridViewReport.RowCreated

          If e.Row.RowType = DataControlRowType.DataRow Then

                 Dim myStatus_ID As SqlDataSource = CType(e.Row.FindControl("sqlDeviceStatusAssign"), SqlDataSource)
                 If Not e.Row.DataItem("Status_ID") Is Nothing Then
                                  myStatus_ID.SelectParameters(0).DefaultValue = e.Row.DataItem("Status_ID")
                 End If

       End If

Must declare the scalar variable "@Genre".


   protected void Button1_Click2(object sender, EventArgs e)
        if (TextBox1.Text == "")
            Label1.Text = "Your search opinion is empty, please try again";

Must declare the scalar variable "@memeberName".


I cant get this to work...








must declare the scalar variable @STDate


Can someone explain to me what I am doing wrong here.  I have 2 textboxes "STDate" and "EDDate" and a button for downloading data to a csv file.  However I keep on getting "Must declare scaler variable @STDate.  I have configured the ControlParameter in the Select Parameter of the SQLDatasource so I'm a little confused why I keep on getting the line "Must declare scaler variable @StDate in my CSV File. 

I'm pretty sure if it ever got past the 'declare scalar variable for @StDate it would throw an error for @EDDate.  Luckly one I figure out what i'm doing wrong for the first one I can fix the second one.

Here is the ASP.net code:

 <table style="width: 294%">
                                                        <td align="center" style="width: 1154px">
                                                            <asp:Label ID="Label1" runat="server" Text="Start Date"></asp:Label>
                                                            <asp:TextBox ID="STDate" runat="server"></asp:TextBox>

Must declare the scalar variable "@id"

My code:

How to perform insert, update, delete and select rows in ASP.NET gridview control using stored proce

In this article, we will explore how to add, update, delete and select a record from sql server database using gridview control in a simple way. I'm using visual studio 2010 and sql server 2008 for this sample.

Accessing the different controls inside a GridView control

how we can access a particular control which resides inside a GridView control. In this article I will show you how you can access different controls inside a GridView control. We will see how we can access a TextBox control, a DropDownList control and a ListBox control. If you are working with ASP.NET 1.X then you might want to check out my article Accessing Different Controls Inside a DataGrid.

In-Depth look at the GridView Control

In the last article we looked at few of the new controls available in Asp.net 2.0. We also talked about Grid View Control which has replaced the Asp.net 1.1 DataGrid control for good. In this article we will examine more features of the Grid View control. In this article we will see some of the common operations that can be performed using the GridView control. Apart from these operations there are many more functions that can be performed on the control and which we will see in the later articles
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