Dim diaryreader As SqlDataReader
diarycmd.CommandText = "dashboardusers"
diarycmd.CommandType = CommandType.StoredProcedure
diarycmd.Connection = usersconn
diaryconn.Open()
diaryreader = diarycmd.ExecuteReader()
Dim diaryTable As DataTable = New DataTable()
diaryTable.Load(diaryreader)
Dim dr As DataRow
for each (dr in diaryTable.rows)
Next
This is not working, I am getting a syntax error when i try to do for each dr in diarytable.rows
Aryan Kumar
06-Jul-2023Sure, I can help you with that. Here is an example of how to generate a daterow in a dataset:
VB.Net
This code will create a new DataTable object and add a Date column to it. The code will then generate a daterow in the DataTable object and add it to the DataTable object. Finally, the code will display the contents of the DataTable object on the console.
Here is an explanation of the code:
DataTable
class represents a DataTable object.Columns
property of theDataTable
class gets the collection of columns for the DataTable object.Add
method of theColumns
property adds a column to the collection.NewRow
method of theDataTable
class creates a new DataRow object.Date
property of theDataRow
class sets the value of the Date column.Rows
property of theDataTable
class gets the collection of rows for the DataTable object.Add
method of theRows
property adds a row to the collection.Console.WriteLine
method is used to print the contents of the DataTable object on the console.Sumit Kesarwani
23-Aug-2014You get errors because your braces are set wrong. This would work:
Dim dr As DataRow
For Each dr In diaryTable.Rows
Next