Changing DataRow Rowstate progamatically

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I want to pass a few thousand records to a SQLce database and then insert them in a table
Seems like the fastest way to do it (sql server replication not an option) is to pass a recordset that has all the records marked as DataRowState.Added, then use a dataadapter.update on the recordset

Walking through the dataset and using insert commands was slower

Is there a way quickly change all the rows in a dataset to "added" or to have them marked as added (rather than unchanged) when the dataset is first filled

thanks
 
Have a look at the 'SourceVersion' of the command object. See if that
gives you some ideas. How are you populating the DataTable initially? If
you can create a DataTable and then 'add' the rows via one of the
DataTable.Rows.Add() overrides (thinking specifically of the object[]),
that should give you rows with a RowState of 'Added'.

Suck it and See!!!
 
In current version of DataSet, there is no provision of changing row state
from unchanged to added. However, when you fill the dataset with
SqlDataAdapter, there is a property called AcceptChangesDuringFill that you
can set which will indicate whether to the SqlDataAdapter that it has to do
"AcceptChanges" after the rows have been populated. By default this property
is set to "true". So when you fill the rows with the adapter you'd see the
rows in "unchanged" state by default. By setting AcceptChangesDuringFill
property to "false" you can keep the rows in the Added state.

HTH,
Ravi

Chuck said:
I want to pass a few thousand records to a SQLce database and then insert them in a table.
Seems like the fastest way to do it (sql server replication not an option)
is to pass a recordset that has all the records marked as
DataRowState.Added, then use a dataadapter.update on the recordset.
Walking through the dataset and using insert commands was slower.

Is there a way quickly change all the rows in a dataset to "added" or to
have them marked as added (rather than unchanged) when the dataset is first
filled.
 
Back
Top