Link to home
Start Free TrialLog in
Avatar of jxharding
jxharding

asked on

add row and call its fieldname "ID" to dynamically created dataset

Hi, i want to create a Dataset dynamically,
no problem. i want to add a row called "ID" to my table "MyID"
the problem is adding the row.
i have Row(0) = and this does not work.
i also dont know how to call the row field "ID"

thanks!

        Dim ds As New DataSet
        Dim dt As New System.Data.DataTable("MyID")  
        ds.Tables.Add(dt)

        Dim I As Integer
        For I = 0 To ListView1.Items.Count - 1
            Dim row As DataRow = ds.Tables("MyID").NewRow()
            row(0) = ListView1.Items(I).SubItems(9).Text.Trim.ToUpper
            ds.Tables("MyID").Rows.Add(row)
        Next I

        ds.WriteXml("c:\1.xml")
ASKER CERTIFIED SOLUTION
Avatar of TimCottee
TimCottee
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial