Solved

ASP.NET web service returns dataset.GetXML to ADODB.Recordset compliant xml

Posted on 2004-09-23
7
548 Views
Last Modified: 2013-12-25
My VB6 application uses MSSOAPLib to call a method of an ASP.NET webservice which returns an xml string of a dataset using the dataset.GetXML() method. How would I convert this xml string to a recordset?

Would I also need the schema information, dataset.GetXMLSchema()?

Thanks ~
Vincent
0
Comment
Question by:lunarknight
  • 2
  • 2
7 Comments
 
LVL 29

Accepted Solution

by:
leonstryker earned 125 total points
Comment Utility
Try this:

'From: http://abstractvb.com/code.asp?A=814

Add a reference to MSXML then drop this code in a module. Just call the XMLStringToRecordset function passing in a valid XML document. (Note: the documents format must match a format defined by Microsoft.)

Public Function XMLStringToRecordset(strXML As String) As Recordset
    Dim objStream As ADODB.Stream
    Dim oRecordset As ADODB.Recordset
   
    Set objStream = New ADODB.Stream
   
    objStream.Open
    objStream.WriteText strXML
    objStream.position = 0
   
    Set oRecordset = New ADODB.Recordset
    oRecordset.Open objStream
   
    objStream.Close
    Set objStream = Nothing

    Set XMLStringToRecordset = oRecordset

    Set oRecordset = Nothing
End Function

0
 
LVL 26

Assisted Solution

by:Rejojohny
Rejojohny earned 125 total points
Comment Utility
dataset.getxml returns records in xml format which is in a different format than what is expected by recordsets ... when u do a save of a recordset to an xml format .. all the columns of a particular record gets added as attributes and a node/element is created for each record. but in the case of dataset.getxml, i think the columns gets formatted as nodes of a parentnode instead of attributes .. so what "leonstryker" suggested might not work .. just check it out . another option would be to loop thorugh the xml string and create the recordset dynamically ..
0
 
LVL 26

Expert Comment

by:Rejojohny
Comment Utility
Please do have a look at my comments .. i tried it out later and indeed getxml works the way i have mentioned .. so he has to loop through the xml string to create the recordset ..
0
 
LVL 29

Expert Comment

by:leonstryker
Comment Utility
I believe there should be a split between

leonstryker and Rejojohny
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now