thanks Miha,
I did what u said... but still it is not working... and I got some strange
result also...
First I am not using the Copy() function(but in actual application I need to
do that) and also I am calling the GetChanges() method before calling the
Update() method on DataAdapter. GetChanges() returns the rows as expected.
So Update method should actually update the row in the database.
I also implemented the RowUpdating and RowUpdated event handler and in that
I am getting the Row which I inserted... but
In the RowUpdated event when I check the e.RecordsAffected property, it
is -1, while the DataAdapter.Update method returns 1. I have gone through
whole MSDN documentation and I don't think I am missing anything, but still
something is wrong. Please tell me what is going wrong here..
thanks and regards,
Ashish Sheth
"Miha Markic [MVP C#]" <miha at rthand com> wrote in message
news:O$(E-Mail Removed)...
> Hard to say.
> First, you don't need to invoke Copy() on GetChanges.
> Next, assign GetChanges to a datatable prior to invoking Update and check
> out the table content if there are rows as expected.
> Next, implement RowUpdating and RowUpdated events what they say.
>
> --
> Miha Markic [MVP C#] - RightHand .NET consulting & development
> miha at rthand com
> www.rthand.com
>
> "Ashish Sheth" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > Hi Miha,
> >
> > In my case due to program logic I can't directly execute the
InsertCommand
> > manually. Please find the attached file for the source code. I have
> > modified
> > the code for your understanding but this is what exactly I am doing in
my
> > application. Here Now I am facing anonther problem.. the recordsAffected
> > is
> > now 1 instead of -1... but still it is not updating in the Database... I
> > don't know what's wrong in this code.. please reply as soon as possible.
> >
> > thanks and regards,
> > Ashish Sheth
> >
> > "Miha Markic [MVP C#]" <miha at rthand com> wrote in message
> > news:(E-Mail Removed)...
> >>
> >> "Ashish Sheth" <(E-Mail Removed)> wrote in message
> >> news:(E-Mail Removed)...
> >> > Ya, I am checking all this thing... Actually I am inserting a row in
> >> > the
> >> > Datatable, so GetChanges method is returning me the Datatable with
the
> >> > newly
> >> > inserted rows with RowState as Added. and I am specifying my own
> >> > InsertCommand. After calling the dataAdapter.Update method I am
> > commiting
> >> > the transaction also.
> >> > But when in the debug mode after executing the dataAdapter.Update
> >> > method
> >> > when I see the dataAdapter.RecordsAffected property in the Watch
> >> > window
> >> > it
> >> > is showing -1. and after the transaction is commited when I see the
> >> > Database
> >> > table the row is not inserted. I don't understand what is going wrong
> >> > here.
> >> >
> >> You mean e.RecordsAffected in the RowUpdated event?
> >> What happens if you manually invoke your InsertCommand with some
> >> parameter
> >> values?
> >>
> >> --
> >> Miha Markic [MVP C#] - RightHand .NET consulting & development
> >> miha at rthand com
> >> www.rthand.com
> >>
> >>
> >
> >
> >
>
>