Results 1 to 2 of 2

Thread: Copy Data Table .... any more efficient way ?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Posts
    101

    Question Copy Data Table .... any more efficient way ?

    Good day.

    I have a situation like this: I have a source datatable, which will be copied to a destination datatable, based on column mapping using arrays.

    Codes are like below:

    'datSource = Source datatable
    'datDes = Destination datatable
    'aryMapping (source-column-index) = dest-column-index)

    With datSource
    For intX = 0 To .Rows.Count - 1
    objRow = .Rows(intX)
    objNewRow = datDes.NewRow

    For intY = 0 To .Columns.Count - 1
    objNewRow.Item(aryMapping(intY)) = objRow.Item(intY)
    Next

    datDes.Rows.Add(objNewRow)
    Next
    End With

    This works fine but it raises some performance issue. Is there any more efficient way of doing that ? I tried to use the COPY method in datatable but it copy the whole data and structure of the datatable. Btw, teh source and destiantion datatable come from different data sources.

    Thanks.

    SonicWave

  2. #2

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Posts
    101
    Good day.

    I think the main reason why it's slow because the dataset is binded to a datagrid. I guess the changes in teh dataset would trigger the events in datagrid.

    What I do is just unbind the dataset and populate it, save it then rebind back the dataset with the datagrid.

    It works, at least.

    Cheers.

    SonicWave

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width