-
[RESOLVED] DataTable
Hi, I want to know how can I read a datatable. I am using this code:
objDataAdapter.Fill(objDataSet, "Outlookbar")
lblArchives.Text = CStr(objDataSet.Tables("Outlookbar").Rows(1).ToString)
the second line doesn't return the value I want. Instead it returns System.Data.DataRow.
What should I change?
-
Re: DataTable
-
Re: DataTable
-
Re: DataTable
You're close. You need:
datasetname.Tables(tablename).Rows(rownumber).Item(columnname).ToString()
-
Re: DataTable
A DataTable contains DataRows. Each DataRow contains Items. Think of it as an excel sheet. To read the value of an individual cell, you have to go to that particular cell. To read values from all cells in a row, you can do a loop, something like this
Code:
'Get the 1st row in the datatable
Dim row As DataRow = objDataSet.Tables("Outlookbar").Rows(0)
'Loop thru all the items in that row and get their values
For Each itm As Object in row.Items
Debug.WriteLine(itm.ToString)
Next
-
Re: DataTable
I really, appreciated that you helped me. It works.
thanks