M
Marco
Hi,
I have a strange problem. Most probably I am not seeing something huge,
so... please help.
Here's the problem:
I have a typed DataSet: MPDataSet
I must update a Row on the DB table Product, and the values of this Row are
passed to me through a Web Service, so I do not have the original DataSet.
Here's what I do:
MPDataSet MPDS= new MPDataSet();
//I create a datarow, fill in it the values passed from the WS, trick the DS
into modifying the RowsState to Modified and pass it to Update:
MarketPlaceDL.MPDataSet.ProductRow Row =MPDS.Product.NewProductRow();
Row.ID_Prod=ID_Prod;
///(...) I fill every field
MPDS.Product.Rows.Add(Row.ItemArray);
MPDS.Product.AcceptChanges();
MPDS.Product.LoadDataRow(Row.ItemArray,false); //to modify RowState
Now MPDS.Product[0].RowState==Modified, then I create a DataAdapter,
create its UpdateCommand and I call
DA.Update(MPDS.Product);
But nothing is updated, the query is never called BUT RowState==unchanged,
thus the DA called AcceptChanges(). I've checked the DA and seems OK.
The weird thing is that if I substitute
MarketPlaceDL.MPDataSet.ProductRow Row =MPDS.Product.NewProductRow();
Row.ID_Prod=ID_Prod;
///(...) I fill every field
MPDS.Product.Rows.Add(Row.ItemArray);
with a query like "Select * from product where id_prod="+ID_Prod the row is
populated (with the values as in the previous way) and, magic, the
subseguent call to Update() really updates!
This seems to show that the RowState=Modified is not enough to make the DA
call the UpdateCommand. IT seems like if the DA can tell if a Row really is
populated from a query. But since I used a Typed Dataset, I thought that it
had all the needed infos to map a row to its parent datatable...
Any clue? Thanks in advance, I am in deep muddy troubles..
Marco
I have a strange problem. Most probably I am not seeing something huge,
so... please help.
Here's the problem:
I have a typed DataSet: MPDataSet
I must update a Row on the DB table Product, and the values of this Row are
passed to me through a Web Service, so I do not have the original DataSet.
Here's what I do:
MPDataSet MPDS= new MPDataSet();
//I create a datarow, fill in it the values passed from the WS, trick the DS
into modifying the RowsState to Modified and pass it to Update:
MarketPlaceDL.MPDataSet.ProductRow Row =MPDS.Product.NewProductRow();
Row.ID_Prod=ID_Prod;
///(...) I fill every field
MPDS.Product.Rows.Add(Row.ItemArray);
MPDS.Product.AcceptChanges();
MPDS.Product.LoadDataRow(Row.ItemArray,false); //to modify RowState
Now MPDS.Product[0].RowState==Modified, then I create a DataAdapter,
create its UpdateCommand and I call
DA.Update(MPDS.Product);
But nothing is updated, the query is never called BUT RowState==unchanged,
thus the DA called AcceptChanges(). I've checked the DA and seems OK.
The weird thing is that if I substitute
MarketPlaceDL.MPDataSet.ProductRow Row =MPDS.Product.NewProductRow();
Row.ID_Prod=ID_Prod;
///(...) I fill every field
MPDS.Product.Rows.Add(Row.ItemArray);
with a query like "Select * from product where id_prod="+ID_Prod the row is
populated (with the values as in the previous way) and, magic, the
subseguent call to Update() really updates!
This seems to show that the RowState=Modified is not enough to make the DA
call the UpdateCommand. IT seems like if the DA can tell if a Row really is
populated from a query. But since I used a Typed Dataset, I thought that it
had all the needed infos to map a row to its parent datatable...
Any clue? Thanks in advance, I am in deep muddy troubles..
Marco