Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 189
  • Last Modified:

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
0
gringogordo
Asked:
gringogordo
  • 2
1 Solution
 
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
 
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

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now