I have a SQLDataAdapter created with the wizard and having all of the
commands including the DeleteCommand - I used the defaults.

To delete a record, this works just fine:
myDA.SelectCommand.Parameters("@mykey").Value = mykey
myDS.Clear()
myDA.Fill(myDS)
If myDS.mytable.Rows.Count > 0 Then
myDS.mytable.Rows.Item(0).Delete()
myDA.Update(myDS)
End If

However, it seems that I should be able to do this in a more straightforward
manner using the DeleteCommand. How should this be done with a minimum of
code?
thanks,
T

Re: Delete Record Question by William

William
Mon May 31 14:02:38 CDT 2004

Just call myTable.Rows.Item(Whatever).Delete

I can't really tell what this is supposed to do, but if you just want to
delete a record, fill in Whatever with the index and it'll delete the
record. When you call Update, the adapter will check all of the rows with a
rowstate or Deleted and issue the delete command against that record, one by
one for each row who's rowstate has been changed (deleted in this case).

--

W.G. Ryan, eMVP

http://forums.devbuzz.com/
http://www.knowdotnet.com/williamryan.html
http://www.msmvps.com/WilliamRyan/
http://www.devbuzz.com/content/zinc_personal_media_center_pg1.asp
"Tina" <tinamseaburn@removespamexcite.com> wrote in message
news:uIQaD$zREHA.3476@tk2msftngp13.phx.gbl...
> I have a SQLDataAdapter created with the wizard and having all of the
> commands including the DeleteCommand - I used the defaults.
>
> To delete a record, this works just fine:
> myDA.SelectCommand.Parameters("@mykey").Value = mykey
> myDS.Clear()
> myDA.Fill(myDS)
> If myDS.mytable.Rows.Count > 0 Then
> myDS.mytable.Rows.Item(0).Delete()
> myDA.Update(myDS)
> End If
>
> However, it seems that I should be able to do this in a more
straightforward
> manner using the DeleteCommand. How should this be done with a minimum of
> code?
> thanks,
> T
>
>