Easy Dataset Question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

How would I get at a certain piece of data in a dataset. For example, how
would I specify first row, first column. What seems logical to me doesn't
work.

Dim strResult as String = myDataset(0).Row(0).Column(0).ToString
 
DataSet does not directly contain DaraRow:( It contains DataTables and
DataTable has DataRows: taht is DataSet->DataTable->DataRow. So you should

Dim strResult as String = myDataset.Tables(0).Row(0).Column(0).ToString

Of cource, you have to make sure there IS a table in the DataSet and there
IS a DatRow in Tables(0). Or you'll get Exception of "Object reference not
set...."
 
Actually, I think you are more likely to get an Index out of Range exception
in this case... :)
 
Hi for getting the certain piece of data in a dataset you should use
myDataset(0).Row(0)(0).ToString
 
Thanks for your help.

Norman Yuan said:
DataSet does not directly contain DaraRow:( It contains DataTables and
DataTable has DataRows: taht is DataSet->DataTable->DataRow. So you should

Dim strResult as String = myDataset.Tables(0).Row(0).Column(0).ToString

Of cource, you have to make sure there IS a table in the DataSet and there
IS a DatRow in Tables(0). Or you'll get Exception of "Object reference not
set...."
 
....or you could use:

if not isnothing(myDataset) then
Dim strResult as string =
myDataset.Tables(0).Rows(0).ItemArray(0).ToString
end if
 
Back
Top