DataSet - modifying values

  • Thread starter Thread starter Trev
  • Start date Start date
T

Trev

I would be very grateful if someone could help me with this.

I have created a DataSet using Tables.Add(mDataSource), where
mDataSource derives from database expressions.

However, I now need to expand this DataSet by adding new columns with
values obtained
from another database. Each cell in this dataset is defined by row
(tag) and column (key),
so how would I, for example, change the value in row = ExistingRow1,
column = NewKey1 ?

TIA

Trev
 
Trev,
When you say "by adding new columns with values obtained ..." you are
talking about modifying the DataTable (which could be one of 1 or more
Datatables in your DataSet). DataSets don't have "cells". Datatables have
rows, and they have columns, just like a table in a database.

So if myDataTable is the table you want to modify, you can do:

myDataTable.Columns.Add("myNewColumnName");

Now your Datatable has a new column.

To add a row (programmatically):

DataRow row;
row=myDataTable.NewRow();
row["columnName"]=value;
myDataTable.Rows.Add(row);

--Hope that helps.
Peter
 

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

Back
Top