473,480 Members | 1,854 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Trying to update a value in the database. Asp.Net/C#/SQL/VS2005

foolios
5 New Member
I don't really know how to check why it's not working.
I have a try/catch that tells me in the catch that it didn't succeed but not sure how to really know what's going on with it.

Here's my update attempt:

SqlCommand comm = new SqlCommand("UPDATE inventoryTbl SET categoryID = @category WHERE id = @category", conn);

comm.Parameters.Add("@category", System.Data.SqlDbType.SmallInt);
comm.Parameters["@category"].Value = txtbx_itemCategory.Text;

try
{
// Execute the command
comm.ExecuteNonQuery();
// Reload page if the query executed successfully
//Response.Redirect("addrelatives.aspx");
}
catch
{
// Display error message
bttnApplyChanges.Text = "Error";
}
finally
{
// Close the connection
conn.Close();
}
Oct 5 '07 #1
2 1096
foolios
5 New Member
Slight mistake, but still doesn't work when it appears to be corrected:

SqlCommand comm = new SqlCommand("UPDATE inventoryTbl SET categoryID = '@category' WHERE id = '@ID'", conn);
Oct 5 '07 #2
foolios
5 New Member
Removed the quotes, working.
Oct 5 '07 #3

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

Similar topics

2
10538
by: Mark | last post by:
A beginner in this area, I have been able to read a record from a MySQL database and populate an HTML form (wow!). Now, my goal is to allow the user to edit the contents of the form and then...
11
3557
by: HolaGoogle | last post by:
hi all, can you please tell me what i should do to avoid session timeout when displaying my database info in my asp form (DisplayUserDatabase.asp)??? ** actualy it does load and display the...
25
4025
by: Neo Geshel | last post by:
This works: <form> <asp:TextBox id="name" /> <%= name.ClientID %> </form> But this DOES NOT work: <form>
8
2669
by: Zorpiedoman | last post by:
I keep getting a concurrency exception the second time I make a change and attempt to update a dataadapter. It appears this is by design, so there must be something I can do to avoid it. ...
1
2462
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...
30
3347
by: Charles Law | last post by:
Here's one that should probably have the sub-heading "I'm sure I asked this once before, but ...". Two users are both looking at the same data, from a database. One user changes the data and...
1
1073
by: John Wright | last post by:
I have a class that I populate properties from a table in my database. I create the properties in my class one for one with the columns in the tables that I use to fill the class. Some properties...
0
1083
by: Tavalss | last post by:
Have developed ASP.Net app using VS2005. App uses Visual Foxpro database via VFPOLEB provider. When in VS2005 development mode I can 'Insert' rows into database tables with no problem. I...
0
1456
by: JDS | last post by:
I have a table with the primary key as a uniqueidentifier / GUID and the rowguid property set (it is used for replication). When creating a data table in a dataset in VS2005 the table adapter...
0
7054
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
7102
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...
1
6756
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
7003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
4495
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3000
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1310
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
570
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
199
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.