473,405 Members | 2,349 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,405 software developers and data experts.

ASP.NET problem GridView and UpdateParameters

Hi all,

I'm really stuck here. I've got a GridView on my page and I want to use the update features to-- well, update. Here is my block of code in the SqlDataSource section:

Expand|Select|Wrap|Line Numbers
  1.         <asp:SqlDataSource ID="SqlDataSource3" runat="server" ConnectionString="<%$ ConnectionStrings:ConnectionStringTraining %>"
  2.             ProviderName="<%$ ConnectionStrings:ConnectionStringTraining.ProviderName %>"
  3.             SelectCommand="SELECT training_unit_id, training_unit_name, training_unit_type, training_unit_frequency FROM training_units order by training_unit_name"
  4.             UpdateCommand="UPDATE training_units SET training_unit_name = @training_unit_name, training_unit_type = @training_unit_type, training_unit_frequency = @training_unit_frequency WHERE training_unit_id = @training_unit_id">
  5.                 <UpdateParameters>
  6.                     <asp:Parameter Name="training_unit_name" Type="String" />
  7.                     <asp:Parameter Name="training_unit_type" Type="String" />
  8.                     <asp:Parameter Name="training_unit_frequency" Type="String" />
  9.                     <asp:Parameter Name="training_unit_id" Type="Int32" />
  10.                 </UpdateParameters>
  11.         </asp:SqlDataSource>
  12.  
I can open the GridView just fine and I can edit it just fine, but when I do the update, I get the error message: "Must declare variable '@training_unit_name'." and, of course, nothing is stored.

What am I doing wrong? I've been working on this for hours and I keep going in circles. All the documentation I've found indicates this is perfectly legitimate.

Thanks in advance.

Robert Porter
Apr 10 '08 #1
2 1046
Hi again,

As a follow-up to my own question, I got it working (sort of) by removing the variable tags (the @ references) and just using the "?" symbols. Very strange.

Of course, now it's not updating my bound variables, but that's another topic.

Robert
Apr 11 '08 #2
*Sigh!* I've got a lot to learn. I've just discovered TableAdapters. That solves yet another problem.

Robert
Apr 11 '08 #3

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

Similar topics

3
by: Dabbler | last post by:
I have a checkbox control in a GridView EditItemTemplate. My SqlDataAdapter complains when I try and use UpdateCommand Thanks on any binding clarification. GridView: <asp:TemplateField...
2
by: dba123 | last post by:
How do I take my GridView and create a function that will update -all- checkbox values for the submit button's OnClick event? I have posted both my SQLDataSource and my GridView below: ...
0
by: Mike P | last post by:
Where exactly are the updateparameters of a gridview picked up from? I have created 2 very similar gridviews and given the updateparameters the same names as in my edititemtemplates. Yet this...
0
by: Mike P | last post by:
How do you get access to the values you have entered under edit mode in a gridview? I only seem to be able to access the values prior to them being edited. protected void...
3
by: Jon Paal | last post by:
this text keeps showing up in my gridview dropdownlist "System.Data.DataRowView" How do I prevent this problem ?
0
by: Deepak Palkar | last post by:
Hi I have Gridview and DetailView both on one page. I am showing the list in the Gridview and the particular record in DetailView. the problem is When i EDIT on the DetailView and try to UPDATE...
4
by: mohaaron | last post by:
This seems like it should be simple to do but for some reason I have been unable to make it work. I would like to databind a SqlDataSource to a GridView during the click event of a button. This...
0
by: KeesH | last post by:
Hi, I am quite desperate now because I made a nice webshop with a gridview where the customer is able to update the amount of products (Hostas in my situation) or delete the row. The problem is...
2
by: William LaMartin | last post by:
On webform, I am populating a GridView from a SQLDatasource based on a MySQL table named PIB. There is no vb code involved. Everything is done in the source for the aspx page, provided below. ...
2
by: xMetalDetectorx | last post by:
Hi Everyone, I have a very simple web app that uses .Net 2.0 login control to authenticate users and allow access to an "admin" folder. Inside that admin folder I have one page that has a...
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...

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.