Tuesday 16 January 2018

Add a datarow in datatable at specified index

DataTable existingDataTable = GetMeDataFromSomeWhere();
//Add a new row to table
DataRow newRow = existingDataTable.NewRow();

newRow["ID"] = 999;
newRow["SomeColumn"] = "Manas Bhardwaj";

existingDataTable.Rows.Add(newRow);

//OR If nedd row add in a specific row 

existingDataTable.Rows.InsertAt(dr, 0);

No comments:

Post a Comment

Get all non-clustered indexes

DECLARE cIX CURSOR FOR     SELECT OBJECT_NAME(SI.Object_ID), SI.Object_ID, SI.Name, SI.Index_ID         FROM Sys.Indexes SI             ...