473,322 Members | 1,690 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Dataset Object updating

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
2 1166
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
"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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Vik | last post by:
A dataset is saved in session state. Then the dataset is filled out with the new records using a dataadapter. It appears then that the dataset saved in session state contains the new records even...
0
by: Vijay Balki | last post by:
I am fetching data in DataSet - myDataSet, from a remote database using a Web Service in my VB.NET client..Once I fetch it I store the data in XML file (myXMLFile) using the WriteXML method of the...
4
by: Dave Taylor | last post by:
I've been using the dataset designer in Visual Studio to create typed datasets for my application by dragging over tables from the Server Explorer and dropping them into the designer. The problem...
14
by: Lars Netzel | last post by:
A little background: I use three Datagrids that are in a child parent relation. I Use Negative Autoincrement on the the DataTables and that's workning nice. My problem is when I Update these...
1
by: batista | last post by:
Hello all, I have a third praty grid control...named C1grid. Im using it in one of my apps.. Now, I have bind this grid to a custom dataset class named "DataViewEx". The code of the class is...
0
by: Johnny | last post by:
I have a PocketPC mobile application that gets its data from the Sql Server database via a web service. The web service returns a dataset that I need to load into the SqlCe database on the mobile...
2
by: Carl Heller | last post by:
Working in VS2003, .Net 1.1 I'm working on a project where I compare data between two databases. This is a lengthy process, and very data intensive, so I decided to create a class, and thread...
2
by: Sheikko | last post by:
ADO.NET - Working with DataSet ========================= HI, I want to create an application that interact with a DB. I wont to use SQL statement, but I want to use DataSet. - I have created my...
1
by: Neil Chambers | last post by:
This is more likely a question for an SQL group but as I'm using powershell and dotnet it may be relevant Overview: I'm trying to pull data from Excel into a DataSet - modifying the DataSet -...
1
by: jonbartlam | last post by:
Hi There I'm not sure what exactly is going wrong here. I'm writing an application that retreives a table from a database (tbl_internalfaults) and updates it. (Actually, just the status column will...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.