slow performance with datatable column update

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

    #1

    slow performance with datatable column update

    Hi - can anyone comment on why performance would be so
    slow to update a DataTable row a simple value? With 3000
    rows, it takes 5 seconds, which is unacceptable. Sample
    code below. Suggestions?

    string colName = "seg_qty";
    for (int i=0; i<mwbView.Count ; i++)
    {
    mwbView[i].Row.BeginEdit( );
    mwbView[i].Row[colName] = 0;
    mwbView[i].Row.EndEdit();
    }

    Thanks,
    Rich G


  • davidw

    #2
    Re: slow performance with datatable column update

    Use one sql statement.

    "Rich G" <richgottesman@ crd.com> wrote in message
    news:007a01c36c c6$f7130890$a60 1280a@phx.gbl.. .[color=blue]
    > Hi - can anyone comment on why performance would be so
    > slow to update a DataTable row a simple value? With 3000
    > rows, it takes 5 seconds, which is unacceptable. Sample
    > code below. Suggestions?
    >
    > string colName = "seg_qty";
    > for (int i=0; i<mwbView.Count ; i++)
    > {
    > mwbView[i].Row.BeginEdit( );
    > mwbView[i].Row[colName] = 0;
    > mwbView[i].Row.EndEdit();
    > }
    >
    > Thanks,
    > Rich G
    >
    >[/color]


    Comment

    • Rich G

      #3
      Re: slow performance with datatable column update

      The code in the sample was a simple code snippet. In the
      real world, I need to be able to set each row to a
      different (calculated) value perhaps stored in an array.
      One SQL statement is not possible, unless there is one for
      each row.

      I basically need to set a datatable column (1..rowcount)
      to take on the values of an array of the same length/type.

      Comment

      • Calvin

        #4
        Re: slow performance with datatable column update

        you are using data binging, which is slower on performance and easier on
        you. sql or sproc.

        Rich G wrote:
        [color=blue]
        > Hi - can anyone comment on why performance would be so
        > slow to update a DataTable row a simple value? With 3000
        > rows, it takes 5 seconds, which is unacceptable. Sample
        > code below. Suggestions?
        >
        > string colName = "seg_qty";
        > for (int i=0; i<mwbView.Count ; i++)
        > {
        > mwbView[i].Row.BeginEdit( );
        > mwbView[i].Row[colName] = 0;
        > mwbView[i].Row.EndEdit();
        > }
        >
        > Thanks,
        > Rich G
        >
        >[/color]

        Comment

        Working...