Dataset Object updating

T

tshad

Is there a way to update a DataSet Object?

I have a Dataset Object (DataSetObj.Tables(0) - one table) that I read in
from a .csv file.

I normally do the following to get my data from the .csv:

Dim DataSetObj As New DataSet
Dim DTDepartment As New DataTable
Dim dt As New DataTable

Dim da As New OleDb.OleDbDataAdapter("Select * from " & "temp.csv", conn)
da.Fill(DataSetObj)

I can get some rows by doing the following:

drCollection = DataSetObj.Tables(1).Select("F1 = 'FRANK'")

Is there a way to Update the tables inside the Dataset?

For example: I would like to change the all the values in Column 1 to 1084
if Column 4 = 'Retirement' and change all the values to 5300 if Column 4 =
'Medicare Employer' etc.

I would then read the file and output it to another .csv file.

Thanks,

Tom
 
J

Jonathan Boivin

Hi there,

I never tried out with a CVS file, but with a database it works fine.

The only thing you have to do is retreiving the data you need to change
using the Select method. Then you modify the column you need by using
ds.Tables("TABLENAME").Rows(ROWINDEX)("COLUMNNAME") = YOURVALUE in a For
loop. And finally, you use your DataAdapter Update method to save to the CVS
file.

Hoping this works,
Jonathan Boivin
 
T

tshad

Jonathan Boivin said:
Hi there,

I never tried out with a CVS file, but with a database it works fine.

The only thing you have to do is retreiving the data you need to change
using the Select method. Then you modify the column you need by using
ds.Tables("TABLENAME").Rows(ROWINDEX)("COLUMNNAME") = YOURVALUE in a For
loop. And finally, you use your DataAdapter Update method to save to the
CVS file.

I was hoping to do a bunch of updates as I would with sql. The loops would
do what I need to do. I would need to do a loop for each change or one loop
with a lot of if statements. I was hoping to do the update to stop that.
But the for loop will work.

How would I do the DataAdapter Update method to update the .cvs file using
the statements below?

Thanks,

Tom

In the DataAdapter can you do
 

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

Top