Updating a column in a DataTable...

  • Thread starter Thread starter Jim Bancroft
  • Start date Start date
J

Jim Bancroft

Ok, I'm sure this one has been asked before, so I'll apologize upfront.
What I'd like to do is take a DataTable and run an update statement against
one of its columns.

Say for instance, my DataTable has a ProductID column, which is an integer,
and I'd like to update all values in that column to something like 33786.
What's the best way to do it? Would a SQL-like statement work combined with
a DataAdapter, or is it not that simple?
 
Hi Jim,

SQL-like style will not work in this case, because DataTables do not support
any-SQL-like statements. Closest to SQL is a Select method of dataTable,
which is something like WHERE clause. You need to loop through the rows and
update them one-by-one. But if your have to update just specific rows, then
you could first use Select method to select these rows (if they could be
selected based on some condition) into array and loop through this array
 
Back
Top