creating dataset from datarowcollection

M

Matt Tapia

I have a datarow collection (drAccountInfo), and I want to add each row to a
datatable that is then added to a dataset...here is my code:

Dim iCount As Integer
Dim myDataTable As New DataTable

For iCount = 0 to drAccountInfo.Length-1
Trace.Warn(iCount)
myDataTable.ImportRow(drAccountInfo(iCount))
Next iCount

Dim myDataSet As New DataSet
myDataSet.Tables.Add(myDataTable)
myDataSet.WriteXML("C:\inetpub\wwwroot\myapp\myfile.xml")

Everytime I run it, I get a blank dataset, but I know there is data in the
datarow collection. What gives?
 
G

Grzegorz Danowski

U¿ytkownik "Matt Tapia said:
I have a datarow collection (drAccountInfo), and I want to add each row to
a datatable that is then added to a dataset...here is my code:

Dim iCount As Integer
Dim myDataTable As New DataTable

For iCount = 0 to drAccountInfo.Length-1
Trace.Warn(iCount)
myDataTable.ImportRow(drAccountInfo(iCount))
Next iCount

Why don't you use merge method? For example:
myDataSet.Merge(drAccountInfo)

Hope it helps.
Grzegorz
 

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

Top