By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,070 Members | 1,238 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,070 IT Pros & Developers. It's quick & easy.

Dataset Object updating

P: n/a
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
Mar 27 '07 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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
---
jo************@cints.net | http://www.cints.net
"tshad" <t@home.coma écrit dans le message de news:
ee**************@TK2MSFTNGP02.phx.gbl...
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


Mar 27 '07 #2

P: n/a
"Jonathan Boivin" <dj**@cyberinternautes.netwrote in message
news:uz*************@TK2MSFTNGP04.phx.gbl...
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
>
Hoping this works,
Jonathan Boivin
---
jo************@cints.net | http://www.cints.net
"tshad" <t@home.coma écrit dans le message de news:
ee**************@TK2MSFTNGP02.phx.gbl...
>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



Mar 27 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.