473,383 Members | 1,795 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

Update error in GridView

Hi,

This should be ridiculously simple, but I just can't get the update to work in GridView for ASP.NET. Here's the very simplified code:

Expand|Select|Wrap|Line Numbers
  1.             <asp:SqlDataSource id="ProductsSource" Runat="Server"
  2.                 ConnectionString="<%$ ConnectionStrings:ConnectionStringTraining %>"
  3.                 ProviderName="<%$ ConnectionStrings:ConnectionStringTraining.ProviderName %>"
  4.                 SelectCommand="SELECT training_unit_id, training_unit_name FROM training_units"
  5.                 UpdateCommand="UPDATE training_units SET training_unit_name=@training_unit_name
  6.                      WHERE training_unit_id=@training_unit_id"
  7.             />
  8.  
  9.             <asp:GridView id="EditGrid" DataSourceID="ProductsSource" Runat="Server"
  10.                   AutoGenerateEditButton="True"
  11.                   DataKeyNames="training_unit_id"/>
  12.  
The select runs fine, but when I try to do the update (hit "Edit", make a change, then hit "Update"), I get the message: Must declare variable '@training_unit_name'. I've tried uisng the UpdateParameters tag, but to no avail.

This is pretty simple. Why isn't it working?

Robert
Apr 14 '08 #1
0 827

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Scott F K Hooper | last post by:
VB.NET 2.0 project... I have an Access database with a table that has one primary key. I have used the Add TableAdapter wizard in VS2005 to create my TableAdapter. Next I added an ObjectDataSource...
1
by: Scott F K Hooper | last post by:
My ASP.NET 2.0 project has a GridView that I want to be able to edit and update records with. The GridView has been bound to an ObjectDataSource control that has the following Update method...
3
by: tarscher | last post by:
Hi all, I have a grid that contains 7 columns from 3 tables (3 unique keys, 4 normal fields). I show this 7 columns on the gridview. I now want to add edit and delete functionality. This should...
0
by: troyblakely | last post by:
I have a gridview which is pulling data from a SqlDataSource, the select command queries a view and the update command is a stored procedure. I'm using a stored procedure because several tables...
4
by: tim.cavins | last post by:
I have a GridView populated by an ObjectDataSource. I am having issues passing the parameters to the objectdatasource. I have verified that the method is being called but none of the parameters...
2
by: Looch | last post by:
Hi, I'm filling a GridView with a simple sproc select statement. I'm trying to use the Update tab to create an update statement and using the following: Update Shipping_Requests Set Shipped...
0
by: Jeff | last post by:
hey asp.net 3.5 I have 2 UpdatePanels in my webpage. This webpage has a GridView, which one of its column is a templatefield which again contain a UpdatePanel and a button... The other...
2
by: Danielle | last post by:
Hello all - Thank you in advance for any help you are able to provide. I am populating a gridview from a stored procuedure. The returned data is a name, phone number, email and guid of a...
5
by: cmrchs | last post by:
Hi, I'm trying out Databinding to a Data Acces Layer using a ObjectDataSource-control The Update works fine but the Delete-method doesn't. when debugging I see that my productID-parameter is...
4
by: ahling | last post by:
Hi all. As mentioned in my first post, I'm currently doing an asp.net blog where user can update their profile, and update their blog entry. But I encountered problem with the update of entry...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.