DataTable.remove problem

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Agnes

    #1

    DataTable.remove problem

    I need to Load 4thousand record into a datagrid for the user to choose.
    After the user click the row, I will save it.
    Now, How can I remove the uncheck row.
    Dim myDelRowArray() As DataRow = dtRvDetail.Sele ct("check = false ")
    Me.dtRvDetail.R ows.Remove(myDe lRowArray) <-- I know there is error, since i
    cannot delete the datarowarray.

    Any simple and easy way ??
    thanks a lot



  • Jay B. Harlow [MVP - Outlook]

    #2
    Re: DataTable.remov e problem

    Agnes,
    Use a for each on your DataRow array removing each entry.

    Something like:

    For Each row As DataRow In dtRvDetail.Sele ct("check = false ")
    dtRvDetail.Rows .Remove(row)
    Next

    Because DataTable.Selec t returns an array of Rows, you can safely remove the
    rows from the underlying DataTable.Rows collection.

    Hope this helps
    Jay

    "Agnes" <agnes@dynamict ech.com.hk> wrote in message
    news:uicveUbiFH A.3164@TK2MSFTN GP15.phx.gbl...
    |I need to Load 4thousand record into a datagrid for the user to choose.
    | After the user click the row, I will save it.
    | Now, How can I remove the uncheck row.
    | Dim myDelRowArray() As DataRow = dtRvDetail.Sele ct("check = false ")
    | Me.dtRvDetail.R ows.Remove(myDe lRowArray) <-- I know there is error, since
    i
    | cannot delete the datarowarray.
    |
    | Any simple and easy way ??
    | thanks a lot
    |
    |
    |


    Comment

    • Agnes

      #3
      Re: DataTable.remov e problem

      Thanks Jay,
      I try the following for-loop before, However, my table got 4000 records. it
      takes too many times to remove it.
      over 5-8 minutes. my client complaint that.
      "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP @msn.com> ¼¶¼g©ó¶l¥ó·s»D: %23f9pWtbiFHA.1 412@TK2MSFTNGP0 9.phx.gbl...[color=blue]
      > Agnes,
      > Use a for each on your DataRow array removing each entry.
      >
      > Something like:
      >
      > For Each row As DataRow In dtRvDetail.Sele ct("check = false ")
      > dtRvDetail.Rows .Remove(row)
      > Next
      >
      > Because DataTable.Selec t returns an array of Rows, you can safely remove
      > the
      > rows from the underlying DataTable.Rows collection.
      >
      > Hope this helps
      > Jay
      >
      > "Agnes" <agnes@dynamict ech.com.hk> wrote in message
      > news:uicveUbiFH A.3164@TK2MSFTN GP15.phx.gbl...
      > |I need to Load 4thousand record into a datagrid for the user to choose.
      > | After the user click the row, I will save it.
      > | Now, How can I remove the uncheck row.
      > | Dim myDelRowArray() As DataRow = dtRvDetail.Sele ct("check = false ")
      > | Me.dtRvDetail.R ows.Remove(myDe lRowArray) <-- I know there is error,
      > since
      > i
      > | cannot delete the datarowarray.
      > |
      > | Any simple and easy way ??
      > | thanks a lot
      > |
      > |
      > |
      >
      >[/color]


      Comment

      • Jay B. Harlow [MVP - Outlook]

        #4
        Re: DataTable.remov e problem

        Agnes,
        | I try the following for-loop before, However, my table got 4000 records.
        it
        | takes too many times to remove it.
        | over 5-8 minutes. my client complaint that.
        The code I gave should take fractions of a second. 5 -8 seconds tops! On my
        Pentium III 866 its takes 00:00:00.240345 6 (thats .24 seconds) to delete
        3999 rows.

        What size of a machine are you running on?
        How much memory?
        What OS?
        What is is going on on the machine?


        Instead of removing the "check = false" rows, have you considered importing
        the "check = true" rows into a new (cloned) datatable?

        Something like:
        Dim checked As DataTable = dtRvDetail.Clon e()
        For Each row As DataRow In dtRvDetail.Sele ct("check = true")
        checked.ImportR ow(row)
        Next

        Then any further processing occurs on checked instead of dtRvDetail.

        Hope this helps
        Jay

        "Agnes" <agnes@dynamict ech.com.hk> wrote in message
        news:%238azW4bi FHA.3716@TK2MSF TNGP14.phx.gbl. ..
        | Thanks Jay,
        | I try the following for-loop before, However, my table got 4000 records.
        it
        | takes too many times to remove it.
        | over 5-8 minutes. my client complaint that.
        | "Jay B. Harlow [MVP - Outlook]" <Jay_Harlow_MVP @msn.com>
        ¼¶¼g©ó¶l¥ó·s»D: %23f9pWtbiFHA.1 412@TK2MSFTNGP0 9.phx.gbl...
        | > Agnes,
        | > Use a for each on your DataRow array removing each entry.
        | >
        | > Something like:
        | >
        | > For Each row As DataRow In dtRvDetail.Sele ct("check = false ")
        | > dtRvDetail.Rows .Remove(row)
        | > Next
        | >
        | > Because DataTable.Selec t returns an array of Rows, you can safely remove
        | > the
        | > rows from the underlying DataTable.Rows collection.
        | >
        | > Hope this helps
        | > Jay
        | >
        | > "Agnes" <agnes@dynamict ech.com.hk> wrote in message
        | > news:uicveUbiFH A.3164@TK2MSFTN GP15.phx.gbl...
        | > |I need to Load 4thousand record into a datagrid for the user to choose.
        | > | After the user click the row, I will save it.
        | > | Now, How can I remove the uncheck row.
        | > | Dim myDelRowArray() As DataRow = dtRvDetail.Sele ct("check = false ")
        | > | Me.dtRvDetail.R ows.Remove(myDe lRowArray) <-- I know there is error,
        | > since
        | > i
        | > | cannot delete the datarowarray.
        | > |
        | > | Any simple and easy way ??
        | > | thanks a lot
        | > |
        | > |
        | > |
        | >
        | >
        |
        |


        Comment

        Working...