sqlceDataAdapter : insertCommand and updateCommand

  • Thread starter Thread starter mauro
  • Start date Start date
M

mauro

hi ,
probably a simple question , but i don't know ho tobe over :

i have a dataset filled by a dataadapter , until now i could
insert rows OR change rows :
for updating data to server , in the first case i do :


daOrdiniRighe.InsertCommand.CommandText = "INSERT INTO
[OrdiniDetailDetail]([CODNUM ] , [PZO ] , [QTA ] ) VALUES (@p1, @p2, @p3)"
....
then
daOrdiniRighe.Update(g_DSORDDetail.Tables(0))

.... and in the second case (changing the rows) :

daOrdiniRighe.UpdateCommand.CommandText = "UPDATE OrdiniDetailDetail SET
CODNUM = @CODNUM , PZO = @PZO , QTA = @QTA WHERE IDRIGA = @IDRIGA "

then
daOrdiniRigheVar.Update(g_DSORDDetail.Tables(0))

.... now i can change rows AND add rows to the Dataset at the same time ,
so i don't know how to update data to the server , infact
if i use daOrdiniRighe.UpdateCommand i receive error because
of new rows ...

i hope i explained well .

thanks

Mauro
 
hi ,
probably a simple question , but i don't know ho tobe over :

i have a dataset filled by a dataadapter , until now i could
insert rows OR change rows :
for updating data to server , in the first case i do :

daOrdiniRighe.InsertCommand.CommandText = "INSERT INTO
[OrdiniDetailDetail]([CODNUM ] , [PZO ] , [QTA ] ) VALUES (@p1, @p2, @p3)"
...
then
daOrdiniRighe.Update(g_DSORDDetail.Tables(0))

... and in the second case (changing the rows) :

daOrdiniRighe.UpdateCommand.CommandText = "UPDATE OrdiniDetailDetail SET
CODNUM = @CODNUM , PZO = @PZO , QTA = @QTA WHERE IDRIGA = @IDRIGA "

then
daOrdiniRigheVar.Update(g_DSORDDetail.Tables(0))

... now i can change rows AND add rows to the Dataset at the same time ,
so i don't know how to update data to the server , infact
if i use daOrdiniRighe.UpdateCommand i receive error because
of new rows ...

i hope i explained well .

thanks

Mauro

U have to update other table then g_DSORDDetail.Tables(0);

DataTable changesTable = g_DSORDDetail.Tables(0).GetChanges();
daOrdiniRigheVar.Update(changesTable);
 
thank you for your answer ,
but maybe i didn't understood ,

it seems my problem remains :

i use it twice : for insertCommand (for new rows)
and for updateCommand (changed rows) :


daOrdiniRigheVar.InsertCommand.CommandText = "INSERT INTO .....
DataTable changesTable = g_DSORDDetail.Tables(0).GetChanges()
daOrdiniRigheVar.Update(changesTable)

daOrdiniRigheVar.UpdateCommand.CommandText = "UPDATE .....
DataTable changesTable = g_DSORDDetail.Tables(0).GetChanges()
daOrdiniRigheVar.Update(changesTable)



i have errore when i have changed rows :
for the first block (daOrdiniRigheVar.InsertCommand.CommandText .....)
it can't accept changed recors .

Mauro




jplindgren ha scritto:
hi ,
probably a simple question , but i don't know ho tobe over :

i have a dataset filled by a dataadapter , until now i could
insert rows OR change rows :
for updating data to server , in the first case i do :

daOrdiniRighe.InsertCommand.CommandText = "INSERT INTO
[OrdiniDetailDetail]([CODNUM ] , [PZO ] , [QTA ] ) VALUES (@p1, @p2, @p3)"
...
then
daOrdiniRighe.Update(g_DSORDDetail.Tables(0))

... and in the second case (changing the rows) :

daOrdiniRighe.UpdateCommand.CommandText = "UPDATE OrdiniDetailDetail SET
CODNUM = @CODNUM , PZO = @PZO , QTA = @QTA WHERE IDRIGA = @IDRIGA "

then
daOrdiniRigheVar.Update(g_DSORDDetail.Tables(0))

... now i can change rows AND add rows to the Dataset at the same time ,
so i don't know how to update data to the server , infact
if i use daOrdiniRighe.UpdateCommand i receive error because
of new rows ...

i hope i explained well .

thanks

Mauro

U have to update other table then g_DSORDDetail.Tables(0);

DataTable changesTable = g_DSORDDetail.Tables(0).GetChanges();
daOrdiniRigheVar.Update(changesTable);
 
Back
Top