Manipulate Dataset at Runtime

  • Thread starter Thread starter Stewart Saathoff
  • Start date Start date
S

Stewart Saathoff

Hello,

I was wondering if anyone knows how to manipulate datasets at runtime with
different functions. I have a dataset that returns a collection of data,
but I want to manipulate that data into another dataset that would generate
a chart. Here is an Example of what I mean:

ds1 has four fields (Val1, Val2, Val3, Val4)

ds2 should be something like this (Val1, Val1 * .3, Val2, Val2 * 2, Val3,
Val4)

If anyone can point me in the right direction, I would appreciate that. I
have a large collection of records that need to be manipulated.

Stewart
 
DataSets are made up of Tables, which in turn consist of Columns. Each
table holds its various data in Rows.

If you want to manipulate data, you simply access the right column of the
correct row in the table of the DataSet and set the value to whatever you
like (as long as the column permits that type of data).

ds2.Tables(0).Rows(0).Item(0) = ds1.Tables(0).Rows(0).Item(0) *
ds1.Tables(0).Rows(0).Item(1)
 
U¿ytkownik "Stewart Saathoff said:
Hello,

I was wondering if anyone knows how to manipulate datasets at runtime with
different functions. I have a dataset that returns a collection of data,
but I want to manipulate that data into another dataset that would
generate a chart. Here is an Example of what I mean:

ds1 has four fields (Val1, Val2, Val3, Val4)

ds2 should be something like this (Val1, Val1 * .3, Val2, Val2 * 2, Val3,
Val4)

Maybe in your case expression columns will be usefull.
Regards,
Grzegorz
 
Hi Stewart,

What you could do is to create copy of the DataSet and create additional
column inside using Expression property of the DataColumn.
 
By chance have you found similar existing working code? I often try to not
reinvent the wheel: start simple, get it working, then move on.

Others have different styles of development. Code themselves into a corner
then ask for help, for example. I don't go there.

I have code here, for example, that uses DataAdapter1.Fill(ds), then I use
that same ds to Update a second DataAdapter, but granted without your
mentioned intermediate manipulation. I suspect my working code could be
easily modified to suit your purpose.

Jeff
 
Back
Top