Updating a dataset in memory

Hi

I am loading a large amount of data into a datset and I want to update varuious rows from time to time and select particular rows back

I understand but haven't doe it yet that i can select vaious rows back with dataset.Select but is there a way to update them.

So maybe

Dataset.Update - Set Selected = True where Value1 = 7
Dataset.select (Where Selected = true)


Thanks
gringogordoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

cubixSoftwareCommented:
Hi

Firstly in the select statement you setup your SQL selection but without the "WHERE" bit and you select on the table within the dataset

say your table is called Customer you will therefore have a CustomerRow object as well...

dim sql as string = "CreditLimit > 10"
dim rowsFound() as datarow
dim dr as datarow

rowsFound = dataset.Customer.select(sql)
if rowsFound.Length = 0 Then
    row = dataset.Customer.NewCustomerRow
    row.Name = "XYZ Customers"
    row.CreditLimit = 100
    dataset.Customer.AddCustomerRow(row)
else
   for each dr in rowsFound
       dr.CreditLimit = dr.CreditLimit * 2
   next
endif


HTH :)
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
gringogordoAuthor Commented:
Thanks for that.  Its pretty much what I was looking for although I was hoping not to have to loop round.  Although I accept that as you are only looping around the necessary rows this is probably what any under the hood solution would be doing anyway (were it to exist).

I'll assign the points after lunch!

Thanks.
0
cubixSoftwareCommented:
Yeah  it's not the nicest bit of code but we have never found any speed issues with this and then the ease of coding when we finally post back to the database via the dataAdapter.update, e.g. to keep everything in a transaction more than makes up for it!

0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.