By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,646 Members | 2,098 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,646 IT Pros & Developers. It's quick & easy.

Consuming a .NET Webservice in VB6, and Creating a ADO RecordSet

P: 1
Hi All,

I have a simple question.
Howto consume a .NET webservice form VB6.

I have tried very many methods. I currently use MSXML. Here is the piece of code that I use. This works flawlessly. It gets a XML String from the WS, and I'm supposed to parse this for my project. But I thought that is a very cumbersome process. I'd like a easier method than just parsing the XML and iterating it. I guess most of you would agree with me in this respect.

Ok lets look at the code..

Dim oSoapClient As MSSOAPLib30.SoapClient30
Set oSoapClient = New MSSOAPLib30.SoapClient30

Call oSoapClient.MSSoapInit("http://localhost/sample/Sample.asmx?wsdl")

' The WS expects 2 parameters, the username and password
' I provide the same by calling the method GetSampleData
' This returns some sample data that needs to be used in VB6 application

Dim xmlString As String
xmlString = oSoapClient.GetSampleData("ferrari@gmail.com", "march")

Debug.Print xmlString

Well, that is the end of the story. The cariable xmlString contains the XML data that which needs to be parsed. But I dont want to parse it or iterate it.

What I thought was to write this XML to a file. And convert this XML data into a Recordset that we all love to use. It's much easier to go about and manipulate later in the application.

For this I tried the following code XMLStringToRecordset()

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.Close
Set objStream = Nothing

Set XMLStringToRecordset = oRecordset

Set oRecordset = Nothing
End Function

But this throws some error like this "the connection cannot be used to perform this operation. It is either closed or invalid in this context".

I pressume the error is because the recordset cannot be written with plain XML, but it needs to follow the MS Schema.

Does anyone know how to go about this?
Nov 21 '06 #1
Share this Question
Share on Google+
1 Reply


Expert 5K+
P: 8,434
Which statement throws the error?
Nov 22 '06 #2

Post your reply

Sign in to post your reply or Sign up for a free account.