DELETE a row from a datatable

I have a dataAdapter that fills a datatable.
I find the value of the primary key for the row to be deleted
I then attempt to delete the row and update the database

but nothing happens on the update
here is my code

Dim TaskID As Integer
        Dim dr As DataRow
        Dim dt As New DataTable
        Dim prm(0) As DataColumn
        prm(0) = dt.Columns("TASK_ID")
        dt.PrimaryKey = prm

        TaskID = Me.grdV_DEPARTMENT_TASK.Item(Me.grdV_DEPARTMENT_TASK.CurrentRowIndex, 5)
        dr = dt.Rows.Find(TaskID)
            Dim result = daTask.Update(dt)

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

I am not much of an expert   but this is the code i use to delete a record

Private Sub BtnDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnDelete.Click
        Dim intcurrentrecord As Integer = Me.BindingContext(DsStoreAd1, "tblstoread").Position
        mblnDirty = True
        DBStoreAd.Update(DsStoreAd1) 'update data file
        'reload dataset   this will enable bindingcontext events
        'position in datsaet                           = previous record
        Me.BindingContext(DsStoreAd1, "tblstoread").Position = intcurrentrecord - 1

perhaps you need to reload you datatable??

justinwood88Author Commented:
I figured it out I used this code thanks for the help any way

Dim TaskID As Integer
        Dim dr As DataRow
        Dim dt As New DataTable
            dt = Me.DstheTask1.Tables("TASK")
            TaskID = Me.grdV_DEPARTMENT_TASK.Item(Me.grdV_DEPARTMENT_TASK.CurrentRowIndex, 5)
            dr = dt.Rows.Find(TaskID)

            daTask.Update(DstheTask1, "TASK")

            Dim pos = Me.BindingContext(objdsTask, "Bus_Cent_Dept").Position
            Me.BindingContext(objdsTask, "Bus_Cent_Dept").Position = pos

        Catch ex As Exception
        Catch d As SqlClient.SqlException

Please refund my points
PAQed with points refunded (250)

Community Support Moderator

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.