Click to See Complete Forum and Search --> : Best way to modify rows in a DataTable
obsessedandre
February 14th, 2002, 03:18 AM
I have a DataTable, and I need to edit the contents of rows inside the
DataTable, while still maintaing the row's index. What is the best way
for me to do this?
obsessedandre
February 14th, 2002, 03:18 AM
I have a DataTable, and I need to edit the contents of rows inside the
DataTable, while still maintaing the row's index. What is the best way
for me to do this?
Joe Keller
February 14th, 2002, 02:19 PM
USE SQL UDPATE/SET command through ADO
Connection.Execute("UPDATE [Table] SET [Field] = 'Value' WHERE [Field] = 'Key'")
karthick_t
January 25th, 2008, 12:58 AM
Just Loop through the rows inside the datatable and find the exact row and start updating the datarow values.
for each( DataRow myRow in dtTable.Rows)
{
for each(DataColumn myCol in dtTable.Columns)
{
if (myRow [myCol ].ToString() == "KeyValue")
{
myRow [myCol ] = diffValue;
}
}
}
dt.AcceptChanges();
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.