Updating a column in a DataTable...

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?
 
V

Val Mazur \(MVP\)

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top