thanx for the quick response..
What i was thinking would work (although i know now it doesnt) was to get
all the data i need first...
then run a select that should return all the rows that i would like.From
here the only way i could see to get them in a datable again is to run
importRow on each row
this seemed like it would be a waste of cycles... Why cant i just say here
is a array of Rows... IMPORT IT... anyway datasets cant do it..
When i first looked at the problem i was going to do it exactly the same way
as you have, however in some cases i have massive amounts of rows... and
doing a foreach over them would be a bit slow. So i was tyring to find
another way to do it.
If only you could cast a Datarow Array to a DataRowCollection and then run a
simple import...
Actually a great method of a dataset to go along with the table.Select()
method, would be a table.DeleteWhere() type clause where you can type in
valid sql statements that would simply remove rows based on a query.
Anything is better than having to do a foreach to simply remove a few rows.
anyways just my 2 cents worth
daz
"Neil" <Ne**@discussions.microsoft.com> wrote in message
news:4B**********************************@microsof t.com...
The first thing that you need to do is find the row you want to delete,
there are many ways you could do this but one way is to loop through all the
rows looking for the one you need to delete based on this particular value
you mention. Once you have a handle on the row you need to delete simply
call the delete method on the row. e.g. workRow.Delete();. I'm not sure what
your snippet of code is trying to do but it looks like you may have a
misconception in that your creating an array of datarows using the select
method presumalbly to find the row you want to delete and then delete it,
the problem with this is your array of data rows is in no way connected to
the underlying datatable and hence you will only delete the row from the
array not the datatable.
You should note that this does not physically remove the row from the
datatable it just marks it for deletion by changing its row state, you need
to call the AcceptChanges method on the datatable to remove it.
Hope this helps
"Darren Clark" wrote:
I have a data set... in which i need to remove 1 row based on a
particaly name
eg
i have a data set (data) and it has 1 table and N rows.... It has a
column name of [name]
i want to remove all records where the [name] = 'any'
? how syntacically can i do that?
I came up with some hair brained idea.. (althnough it doesnt work.)
DataSet dlocation =
dataMan.CheckCacheData(JR.DataAccess.ContentType.L ocation);
DataRow[] dRow = dlocation.Tables[0].Select("text <> 'Any'");
dlocation.Tables[0].Rows.Clear();
dlocation.Tables[0].Rows = (DataRowCollection)dRow;
this.Location.DataSource = dRow;
this.Location.DataBind();
Any help would be great....