Forms Data Controls :: Binding DropDownList To GridView - Error / .Must Declare The Scalar Variable "@ProductID"

May 25, 2010

i have two tables in my database, product(productid as pk) and productdetails(productid as fk), in a relationship.i have dropdownlist which on pageload displays data from my product table, showing all product name. AutoPostBack enabled. Its working fine.i have a gridview which should display the productdetails data when i select a value from my dropdown list.i have written the code for the gridview on the selected_index_change event of the drop down list, please correct me this is wrong;here is the code;

Protected Sub DropDownList1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Dim ConString As String [code]...

so when i select the value in the dropdownlist i get this error .Must declare the scalar variable "@ProductID".

View 7 Replies

Similar Messages:

DataSource Controls :: How To Insert A Picture On A Gridview / The Error - Must Declare The Scalar Variable

Feb 28, 2010

i would like to insert a picture on a gridview, but i allways get the error:

Must declare the scalar variable "@IMAGEM"

somme one can on tihs code ? here is my code:


View 13 Replies

Web Forms :: Error - Must Declare Scalar Variable

Dec 11, 2012

when I am executing an above code and click on button to insert data is shows an error message

as: System.Data.SqlClient.SqlException: Must declare the scalar variable "@imagefile"

Protected Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.Click
If fileupload1.HasFile Then
'getting length of uploaded file


View 1 Replies

SQL Server :: Using SQL INSERT Command With DataGrid - Must Declare The Scalar Variable Error

Mar 28, 2011

OK, this may be a little difficult to explain, so I will try my best and post the code I currently have.

I have a table with a list of usernames. I have the list of usernames displayed on a page through a GridView. What I am attempting to do is for each username in the column "adminUsernames", I need to insert a set of values in another database table for EACH "adminUsernames" that exists. Example: There are 2 adminUsernames vales in 2 seperate rows. These are "Admin 1" and "Admin 2". For each adminUsername values (Admin 1, Admin 2), I need a row interted in another database table. Maybe the code that I have (that does not work) will help you see what is happening:


I keep receiving this error when running: [Code]....

View 3 Replies

DataSource Controls :: Declare The Scalar Variable @txtSubject?

Mar 24, 2011

I can't figure out whats wrong with my contact page. I am getting this error when executing. It complied fine, I see the page as it suppose to. Then I enter all my contact information and click submit I am getting this error. Can someone guide me. Here is the error msg

must declare the scalar variable @txtSubject Here is the part of relevant code

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSubmit.Click
Dim ContactDataSource As New SqlDataSource()
ContactDataSource.ConnectionString = ConfigurationManager.ConnectionStrings("ASPNETDBConnectionString1").ToString()
ContactDataSource.InsertCommandType = SqlDataSourceCommandType.Text
ContactDataSource.InsertCommand = "INSERT INTO Enquery (EnqSubject,EnqFirstname, EnqLastname,EnqContactNumber,EnqEmail,EnqMsg,EnqDateTimeStamp,EnqIPAddress) values (@txtSubject, @txtFirstname, @txtLastname,@txtPhone,@txtEmail,@txtMsg, @txtDateTimeStamp,@txtIpAddress)"


View 3 Replies

DataSource Controls :: Must Declare The Scalar Variable With Name Parameters?

Mar 1, 2011

I'm getting "Must declare the scalar variable "@ShowTypes"." when I try to run the code below.


View 3 Replies

Web Forms :: Must Declare The Scalar Variable?

Mar 24, 2014

I Am getting error as Must declare the scalar variable "@Imageid" for the following code,while executing,

exec spGetPager  ' ' , ' ', ' 3 ', ' '

In my coding I pass querystring value like 1,2,3 etc

@PageNo int = 1,
@ItemsPerPage int = 1,
@Imageid int,


View 1 Replies

DataSource Controls :: How To Declare Scalar Variable @UserName In Function

Jan 14, 2010

How do I define @UserName in my function:


I believe "UserName" = Me.User.Identity.Name

but I don't know the proper way to add it to the function.

View 6 Replies

Using DataSet In C# Error: Must Declare The Scalar Variable "@city".

Mar 16, 2010

I am trying to fill a dataSet with rows from a table in my SQL Server Express 2008 and I keep getting an error.

Error: Must declare the scalar variable "@city".

using System;
using System.Data;
using System.Data.SqlClient;

The error happens at the adCust.Fill command and I am unsure why. If the variable @city was not declared than why did the WriteLine command work.

View 3 Replies

SQL Server :: Insert Query - Error Must Declare The Scalar Variable "@FirstName"?

Oct 25, 2010

I am attempting to do an insert query on a webpage for a simple member registration form I have created in vs2010. I have done this type of thing before without problem using an access database, but now I'm using a sqlexpress db created from within vs2010. This is the screenshot of my insert query:

Now, when I execute this query in the form, I get an error that says:

Must declare the scalar variable "@FirstName".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 "@FirstName".

Source Error:


Source File: C:UsersCJ PerryDocumentsMy DropboxWebSitesCJ's Test WebsiteRegister.aspx Line: 51 Stack Trace:


Version Information: Microsoft .NET Framework Version:2.0.50727.4952; ASP.NET Version:2.0.50727.4955

At first I just had my query with all ?'s instead of @FirstName, etc in the insert statement itself, but I got an error on that as well but it was different, it just said syntax error near "?" or something to that effect. If I manually perform this query in the builder, and it pops up a window that asks for values on everything, I put something into each field and the insert works great. It just won't work with these parameters for some reason. Can someone advise what I need to do?

View 5 Replies

SQL Server :: Error "Must Declare The Scalar Variable"

Aug 14, 2010


Error "Must declare the scalar variable"

View 3 Replies

SQL Server :: How To Declare Scalar Variable

Aug 5, 2010

how to Declare scalar variable


View 6 Replies

SQL Server :: Select Count Query And Parameters - Error: "Must Declare The Scalar Variable "@KategorijaID"."?

Sep 18, 2010

I have a problem with SELECT COUNT query in I want to create CMS with articles which have categories (which have the option to be deleted). The problem is that I want to get the number of articles within the specified category so if there aren't any articles with the specified category I can proceed with the category deletion.I have the following code:


After I click the button "Obriši" (Delete) I receive the following error: "Must declare the scalar variable "@KategorijaID"." I understand that the problem is with parameter, but I don't know how to correct it to use it for both the "command" and "brisanje" SQLCommands.

View 9 Replies

DataSource Controls :: Must Declare The Scalar Variable "@UserId"?

Mar 30, 2010

am trying to provide users with a number of options, among which, I would like them to see a sum of trips that they have talked about. I have therefore the Trips Table and the Users table. The UserId is the PK of User Table and FK of Trips Table. Trip_Id is PK of Trips Table.In order to see a sum of the number of trips that a user has post, this is the query I have wrote into SQLDATASOURCE:


Everything seems really simple and cannot figure out why when I try to login to test the application , the error I get is: Must declare the scalar variable "@UserId".

View 5 Replies

Must Declare The Scalar Variable "@EmailAddress" On 'command'.ExecuteNonQuery()

May 18, 2010

I keep getting:

Must declare the scalar variable "@EmailAddress" when I'm debugging and my values aren't being submitted to the DB. Can the eyes of the forum see my error?



View 2 Replies

ADO.NET :: Must Declare The Scalar Variable "@NieuwsID"

Sep 6, 2010

I get the error message: Must declare the scalar variable "@NieuwsID".

<%@ 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() {.......

View 3 Replies

Forms Data Controls :: Binding Scalar Values - Get Value In OnItemDataBound?

Jan 21, 2010

I have a question on Scott's article about binding scalar values to data controls: [URL]

On the seconde example (the one using templates), how would I access the scalar value in the controls OnItemDataBound event? e.Item.DataItem seems to be null....

View 2 Replies

Forms Data Controls :: Error Binding A DropDownList Inside DeatilsView?

Apr 9, 2010

I am having problem to do a 2 way binding with DropDownList inside DetailsView, my markup declaration is:


But I am getting the following error messages on the line ddlCategoryId.DataBind(): ArgumentOutOfRangeException: 'ddlCategoryId' has a SelectedValue which is invalid because it does not exist in the list of items.sometimes I get different error: InvalidOperationException: Databinding methods such as Eval(), XPath(), and Bind() can only be used in the context of a databound control.]

View 5 Replies

Forms Data Controls :: Details View With Dropdownlist Error When Binding?

May 4, 2010

<asp:TemplateField HeaderText="Location">

View 1 Replies

Forms Data Controls :: Binding Dropdownlist To Gridview?

May 26, 2010

I have two tables. t1 and t2

t1 is related to t2 through Order Numbers

these order numbers in table t2 have many part numbers(and hence the need for a second table t2)

I can display t1 using gridview just fine

In that same gridview iI have added a template column containing a dropdownlist(to show partnumbers)

now how can I bind this dropdownlist to the order number so that when the page is loaded the user can click on the dropdownlist to see all the partnumbers associated with that order number.

View 3 Replies

Data Controls :: Error When Binding DropDownList From Database

Dec 23, 2013

I am using a dropdown list in gridview and populating it from database.However ,i am getting "object reference not set to an instance ..." error even though i have reference.I have two more similar drop down list and they are working perfectly.

I am uploading the options for the dropdownlist from a "tab delimited" text file for all the dropdown list.I am not getting where exactly the problem is.

<asp:TemplateField HeaderText="Property" HeaderStyle-Wrap="false">
<asp:Label ID="lblProperty" runat="server" Text='<%#Eval("Property")%>'></asp:Label>
<asp:Label ID="lblProperty" runat="server" Visible="false" Text='<%#Eval("Property") %>'></asp:Label>
<asp:DropDownList ID="ddlPropertyEdit" runat="server"></asp:DropDownList>


View 1 Replies

Forms Data Controls :: Binding DropdownList In A GridView To A Datasource?

Sep 8, 2010

I have a Dropdownlist in an itemTemplate in a gridview. My gridView binds to dataTable1 (from which the selected value for dropdown comes from) and dropDown binds to dataTable2 (i need to get DataValueField and DataTextField from here).


View 3 Replies

Access :: Showing All ProductID's, It Shows Only 1 ProductID?

Jun 6, 2010

im trying to display data from an acces database.the problem however is that, instead of showing all productID's, it shows only 1 productID and its new to sql and so im having a hard time getting this doing this in C#.i should note that,after i figure this out, the productID's need to be clickable so it will redirect u to that productID's personal short, a webshop kind of code in the aspx.cs currently looks like this,

protected void Page_Load(object sender, EventArgs e){OleDbConnection verbinding = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source = C:/LOCATION/mydatabase.mdb");try{verbinding.Open();if (verbinding.State.ToString() == "Open"){string sqlstr = "SELECT ProductID, price FROM Product WHERE Producttype='Jeans'";


View 4 Replies

DataSource Controls :: Frustrating In Error "Must Declare The Variable '@Date_Field'"?

May 11, 2010

I am working on this for couple of days but still getting this error message.

SqlCommand sqlInsert;
SqlDataAdapter MySqlAdapter_insert;
SqlCommandBuilder MyBuilder_insert;


View 12 Replies

Forms Data Controls :: Binding DropDownList Datasource In Code Behind For TemplateField In GridView

Feb 23, 2010

I am trying to bind the datasource of a ddl which is located inside the EditTemplate of a TemplateField.When is the best time to bind this datasource (after loading grid, before editing, ? (Note: I must do this in code behind).I am currently trying to bind it on the edit command:


The issue is that the list retrieved from the LoadLists method is null when passing to the LoadList method where the datasource is bound.

View 5 Replies

Copyrights 2005-15, All rights reserved