I have a really weird problem with a web application I am creating. Basically I have a table of inventory items and as stock goes down or notes about the items change I want to be able to edit them. I have done this loads of times before with a editable datagrid and its worked fine. I have been having real problems with editing one
table (you enter the details into the datagrid and it updates but does not change anything) so today I have been doing a little testing to see what the problem is.
I have made a small method that simply updates one field in the database with no user input at all. I went really basic and this statement, although no good to me in this situation, works fine:
I then tried setting the Manufacturer as a parameter and that worked.
I figured it out as if I set the InventoryID to a parameter it does not work, I do not know why as I have coded one of these methods loads of times and they work. I have also tried both parameter declarations shown below:
I can post the rest of the method if you like but the whole updating the database works, just this InventoryID has a problem. Can anyone suggest anything else I can try or see something obvious I have missed out or that I am doing wrong?
Thanks for your time.
table (you enter the details into the datagrid and it updates but does not change anything) so today I have been doing a little testing to see what the problem is.
I have made a small method that simply updates one field in the database with no user input at all. I went really basic and this statement, although no good to me in this situation, works fine:
Code:
string QueryString = "UPDATE INVENTORY SET Manufacturer = 'ATI' WHERE INVENTORYID = '1'";
I then tried setting the Manufacturer as a parameter and that worked.
Code:
string Manufacturer = "ATI";
string QueryString = "UPDATE INVENTORY SET Manufacturer = @Manufacturer WHERE INVENTORYID = '1'";
ObjCmd.Parameters.AddWithValue("@Manufacturer", Manufacturer);
I figured it out as if I set the InventoryID to a parameter it does not work, I do not know why as I have coded one of these methods loads of times and they work. I have also tried both parameter declarations shown below:
Code:
[b]Parameter attempt one[/b]
System.Data.OleDb.OleDbParameter DbParam_InventoryID = new System.Data.OleDb.OleDbParameter();
DbParam_InventoryID.ParameterName = "@InventoryID";
DbParam_InventoryID.Value = 1;
DbParam_InventoryID.DbType = System.Data.DbType.Int32;
ObjCmd.Parameters.Add(DbParam_InventoryID);
Code:
[b]Parameter attempt two[/b]
ObjCmd.Parameters.AddWithValue("@InventoryID", 1);
I can post the rest of the method if you like but the whole updating the database works, just this InventoryID has a problem. Can anyone suggest anything else I can try or see something obvious I have missed out or that I am doing wrong?
Thanks for your time.