Add Get Response Stream data to dataset

I have a process that runs, passes in a single variable  and gets a response from a web service and loads that into a dataset.

Partial code is attached.

I now have to do this in a for each manner.

So what I would like to do is APPEND each incoming response to the dataset and keep everything in one table.

So that if I fed in 20 seperate "single" requests from my list, I can bind to a grid with this code which uses my dataset

Dim dt As DataTable
 dt = New DataTable()
 dt = ds.Tables(0)
Blah...blah..blah...

            ' Get response   
            response = DirectCast(request.GetResponse(), HttpWebResponse)

            ' Load data into a dataset   
            ds = New DataSet()
            ds.ReadXml(response.GetResponseStream())

Blah...blah...blah...

Open in new window

Larry Bristersr. DeveloperAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

volkingCommented:
I think this is what you need.
Understand the below is PSEUDO code that you'll need to change to fit your needs.

Imports System.Data
Imports System.Data.SqlClient

        Dim ds As DataSet = New DataSet()
        ds.Tables.Add(New DataTable("MyTable"))

        ds.Tables("MyTable").Columns.Add(New DataColumn("ColString", System.Type.GetType("System.String")))
        ds.Tables("MyTable").Columns.Add(New DataColumn("ColInt32", System.Type.GetType("System.Int32")))
        ds.Tables("MyTable").Columns.Add(New DataColumn("ColDecimal", System.Type.GetType("System.Decimal")))

        For Each ?Record?
            Dim newRow As DataRow = ds.Tables("MyTable").NewRow()
            newRow.Item("ColString") = Record.STRING?
            newRow.Item("ColInt32") = Record.INTEGER?
            newRow.Item("ColDecimal") = Record.DECIMAL?
        Next

Open in new window


When the loop is done you're built a dataset dynamically in memory
0
CodeCruiserCommented:
Declare a class level dataset

Dim MainDataset As New DataSet

Then load the dataset with the first values so that it has all the structure.

Afterwards do this

            ds = New DataSet()
            ds.ReadXml(response.GetResponseStream())

            MainDataSet.Tables(0).Merge(ds.Tables(0))
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Larry Bristersr. DeveloperAuthor Commented:
Sorry for the late get-back
Perfect...thanks
0
CodeCruiserCommented:
Glad to help :-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.