I am trying to do something that I would expect to be very easy but I am not
having much luck finding the solution.

I have a DataSet containing one data table of potentially 10000's of rows of
data. Using ADO.NET I need to programmatically perform the equivalent of
the following SQL Statement:

UPDATE DataTable1 SET Field1 = 987 WHERE Field2 = 'XYZ';

Is there a way of performing this function directly against the DataSet or
DataTable without iterating through all of the Rows and examining the value
of each field?

Please note that I must perform the updates against the DataTable and not
the original data source.

Any help would be appreciated.

Thanks
John

Re: Update ... Where with a DataSet/DataTable by Marina

Marina
Wed Jan 07 15:30:29 CST 2004

You can use the Select method to get an array of rows matching the WHERE
clause. Then you could iterate through just those rows and set the values
of the other field.

You still have to manually set the value, but at least you don't have to
loop through each one to see if it needs to be updated.

"John M. Collinson" <jcollinson(at)glenbriar.com> wrote in message
news:Ox1BaTW1DHA.404@tk2msftngp13.phx.gbl...
> I am trying to do something that I would expect to be very easy but I am
not
> having much luck finding the solution.
>
> I have a DataSet containing one data table of potentially 10000's of rows
of
> data. Using ADO.NET I need to programmatically perform the equivalent of
> the following SQL Statement:
>
> UPDATE DataTable1 SET Field1 = 987 WHERE Field2 = 'XYZ';
>
> Is there a way of performing this function directly against the DataSet or
> DataTable without iterating through all of the Rows and examining the
value
> of each field?
>
> Please note that I must perform the updates against the DataTable and not
> the original data source.
>
> Any help would be appreciated.
>
> Thanks
> John
>
>



Re: Update ... Where with a DataSet/DataTable by John

John
Thu Jan 08 07:28:06 CST 2004

The problem with the solution that you present is that I do not want to
update the array of rows I want the up DataTable itself.

Also, given you solution I would still end up iterating through every row in
the dataset since the combination of updates that I need to perform would
eventually touch every row.

Thanks for your help Marina.

Do others have any different approaches to how they have solved this
problem?

John

"Marina" <someone@nospam.com> wrote in message
news:e14V6VW1DHA.2460@TK2MSFTNGP10.phx.gbl...
> You can use the Select method to get an array of rows matching the WHERE
> clause. Then you could iterate through just those rows and set the values
> of the other field.
>
> You still have to manually set the value, but at least you don't have to
> loop through each one to see if it needs to be updated.
>
> "John M. Collinson" <jcollinson(at)glenbriar.com> wrote in message
> news:Ox1BaTW1DHA.404@tk2msftngp13.phx.gbl...
> > I am trying to do something that I would expect to be very easy but I am
> not
> > having much luck finding the solution.
> >
> > I have a DataSet containing one data table of potentially 10000's of
rows
> of
> > data. Using ADO.NET I need to programmatically perform the equivalent
of
> > the following SQL Statement:
> >
> > UPDATE DataTable1 SET Field1 = 987 WHERE Field2 = 'XYZ';
> >
> > Is there a way of performing this function directly against the DataSet
or
> > DataTable without iterating through all of the Rows and examining the
> value
> > of each field?
> >
> > Please note that I must perform the updates against the DataTable and
not
> > the original data source.
> >
> > Any help would be appreciated.
> >
> > Thanks
> > John
> >
> >
>
>



Re: Update ... Where with a DataSet/DataTable by Marina

Marina
Thu Jan 08 13:06:06 CST 2004

The array of rows are pointers to the real rows - not copies of them. So you
would be updating the real DataTable.

I don't think there is another way for you to do this, as in the way a SQL
query would.

At this rate, would it be easier to create a temp table in the database (if
not the real one, maybe a temporary access db), dump your data in there, and
then do all the real work.

"John M. Collinson" <jcollinson(at)glenbriar.com> wrote in message
news:u6Y33ue1DHA.2680@tk2msftngp13.phx.gbl...
> The problem with the solution that you present is that I do not want to
> update the array of rows I want the up DataTable itself.
>
> Also, given you solution I would still end up iterating through every row
in
> the dataset since the combination of updates that I need to perform would
> eventually touch every row.
>
> Thanks for your help Marina.
>
> Do others have any different approaches to how they have solved this
> problem?
>
> John
>
> "Marina" <someone@nospam.com> wrote in message
> news:e14V6VW1DHA.2460@TK2MSFTNGP10.phx.gbl...
> > You can use the Select method to get an array of rows matching the WHERE
> > clause. Then you could iterate through just those rows and set the
values
> > of the other field.
> >
> > You still have to manually set the value, but at least you don't have to
> > loop through each one to see if it needs to be updated.
> >
> > "John M. Collinson" <jcollinson(at)glenbriar.com> wrote in message
> > news:Ox1BaTW1DHA.404@tk2msftngp13.phx.gbl...
> > > I am trying to do something that I would expect to be very easy but I
am
> > not
> > > having much luck finding the solution.
> > >
> > > I have a DataSet containing one data table of potentially 10000's of
> rows
> > of
> > > data. Using ADO.NET I need to programmatically perform the equivalent
> of
> > > the following SQL Statement:
> > >
> > > UPDATE DataTable1 SET Field1 = 987 WHERE Field2 = 'XYZ';
> > >
> > > Is there a way of performing this function directly against the
DataSet
> or
> > > DataTable without iterating through all of the Rows and examining the
> > value
> > > of each field?
> > >
> > > Please note that I must perform the updates against the DataTable and
> not
> > > the original data source.
> > >
> > > Any help would be appreciated.
> > >
> > > Thanks
> > > John
> > >
> > >
> >
> >
>
>