Updating a row in a dataset

  • Thread starter Thread starter Jeremy
  • Start date Start date
J

Jeremy

The example for updating an non-strong typed dataset in the resource kit
shows:


dsNorthwind.Tables("ProductsDS").Rows(lstResults.SelectedIndex)("ProductName
") = ProductName & " - Updated"


My code is something like this:

for each srcrow in myds.table(0)
.. do some stuff ..
myds.table(0).rows(rownumber)("fieldname") = 1 <== Question is here
next

I don't have a SelectedIndex to use as a row number. How do I address the
current row? Rows does not have an "itemindex", "currentrow", etc.
property. What do I do?

Jeremy
 
You are already doing a for each, with a 'srcrow' variable, so just use that
to set the field.

If you want to index by number, you have to use a regular for loop, and use
the for variable to index in.
 
Marina, so you're saying that the following does update the dataset?

srcrow("fieldname") = 1

I did try that, so I must have an issue with the update method then.

Thanks.
 
Hi Jeremy,
Marina, so you're saying that the following does update the dataset?

srcrow("fieldname") = 1

I did try that, so I must have an issue with the update method then.

Yes

If you want to test it, set a

messagebox.show(scrow("fieldname").tostring) behind it.

Just to attent you, that "fieldname" is a pseudo?

Cor
 
Back
Top