tags:

views:

118

answers:

1

Hi how to add data to the datatable which has 5columns.

A: 

From the MSDN

void AddRow(DataTable^ myTable){
    DataRowCollection^ rc; 
    DataRow^ myNewRow;
    // Create an array with three elements.
    Object rowVals[] = gcnew Object[3];
    rc = myTable->Rows;
    rowVals[0] = S"hello";
    rowVals[1] = S"world";
    rowVals[2] = S"two";
    // Add and return the new row.
    myNewRow = rc->Add(rowVals);
 }

You'd need to add two new values to rowVals and then you're away with it (P.S. I changed the syntax to cli syntax by eye, it might not compile exactly as it is but should be enough to work with)

Binary Worrier