How to create this dataset? Thank You.

S

Shapper

Hello,

I have a loop for where I want to add data to a dataset.
I already created the dataset:

Dim dsNews As DataSet = New DataSet()
dsNews.Tables.Add
dsNews.Tables(0).Columns.Add("title", GetType(String))
dsNews.Tables(0).Columns.Add("description", GetType(String))

How to create a new row in each For loop Step and assign it values?

Something like:

For i = 1 to 10
NEW ROW
Row.Title = ...
Row.Description = ...
End

Thank You,
Miguel
 
C

chud

Dim row As DataRow = dsNews.Tables(0).NewRow()
With row
.Item("title") = "some title"
.Item("description") = description
End With
dsNews.Tables(0).Add(row)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top