Despite me being able to type the following in to SQL Server and it
updating 1 row:
updatestockcategory 1093, 839
In my code, it is not updating any rows.
dataSet = new DataSet();
dataAdapter = new SqlDataAdapter(SQLCommandString, conn);
dataAdapter.Fill(dataSet, "StockCategory");
dataTable = dataSet.Tables["StockCategory"];
dataAdapter.UpdateCommand = new
SqlCommand("UpdateStockCategory", conn);
dataAdapter.UpdateCommand.CommandType =
CommandType.StoredProcedure;
myParam =
dataAdapter.UpdateCommand.Parameters.Add("@ParentS tockCategoryId",
SqlDbType.Int, 0, "ParentStockCategoryId");
myParam.Value = ParentStockCategoryId;
myParam =
dataAdapter.UpdateCommand.Parameters.Add("@StockCa tegoryId",
SqlDbType.Int, 0, "StockCategoryId");
myParam.Value = StockCategoryId;
MessageBox.Show(dataAdapter.Update(dataSet,
"StockCategory").ToString());
The last line displays how many records were affected, which in this
case is 0. I am absoluetely sure that ParentStockCategoryId and
StockCategoryId have the right values so I don't know what I could be
doing wrong, it's been bothering me for hours!
Thanks