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:
DataTableclass represents a DataTable object.Columnsproperty of theDataTableclass gets the collection of columns for the DataTable object.Addmethod of theColumnsproperty adds a column to the collection.NewRowmethod of theDataTableclass creates a new DataRow object.Dateproperty of theDataRowclass sets the value of the Date column.Rowsproperty of theDataTableclass gets the collection of rows for the DataTable object.Addmethod of theRowsproperty adds a row to the collection.Console.WriteLinemethod 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