Good day folks,

I want to delete some records in my datatable using query. But I don't know how to do it. Can someone help me? Thanks

        For i As Integer = 0 To objChkArray.Count - 1
            Dim rows As DataRow() = dtable.[Delete]("ct = '" & CInt(objChkArray(i)) & "'")
            For Each row As DataRow In rows
                dtable.ImportRow(row)
            Next
        Next

May you try:

dt.AcceptChanges()
dt.Rows.Remove(row)

With 'row' is the row which you want to remove.

What I want is to delete a certain row using a query

I think it probably the same. You can change "Ct='abc'" with your query and "Ct" with your sorting column.

        Dim Dr() As DataRow
        Dr = dt.Select("ct = 'abc'", "ct")
        For i As Integer = 0 To Dr.Length - 1
            dt.Rows.Remove(Dr(i))
        Next

Thanks bro, Great help

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.