how to update all rows in datatable for some columns RRS feed

  • Question

  • my datatable structure and data is:

    col1   col2    col3    col4

    1        pep    25       usa

    2        nos    12       uae

    3        kaa      5       eng

    4        kmm    7        usa


    i need to update all rows (just col2 and col4 data)

    update  col2    to    convert(col2) for all rows

    update  col4    to    convert(col4)  for all rows

    convert:  is a function  (i write it)


    Output datatable is:

    col1   col2    col3    col4

    1        dsk    25       U1

    2        frm    12       U2

    3        cps      5       E1

    4        jhj       7       U1


    • Edited by Ashkan209 Monday, May 19, 2014 3:30 AM
    Monday, May 19, 2014 3:30 AM


  • Hello,

    There is a way for performing batch updates with a dataAdapter, for the DataTable object, not unless you count foreach. One way or another, you'll need to loop since your value is not the same, if they are same, this is possible by using the Expression property as:

    DataSet1.Tables("Orders").Columns("OrderCount").Expression = "Count(OrderID)"

    If I misunderstand, please let me know.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, May 20, 2014 5:31 AM