how do I read values from a specific row of a dataset?

liunx

Guest
Dim _ds As New DataSet
Dim _dt As New DataTable
Dim _dr As DataRow

_ds = myEmployee.fetchEmployees("e100")
_dt = _ds.Tables("tblEmployees")
_dr = _dt.Rows(0)


_dt only has a single record in it that represents the emplyee whose Id = e100, so I have no need to iterate through the rows, I just need _dr to equal the one and only row in _dt.

if I remark out the last line of code the page runs fine, however with the last line in I get:

Value of type 'System.Data.DataRowCollection' cannot be converted to 'System.Data.DataRow'.

I realize that _dt.Rows refers to the datatables rows collection but how do I assign the first row in the collection to a local variable?_ds.tables(0).rows(0).item(0) or
_ds.tables("tblEmployees").Rows(0).Item(0)
 
Back
Top