467,874 Members | 1,761 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,874 developers. It's quick & easy.

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

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
  • viewed: 3519
Share:
1 Reply
Expert 8TB
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.

Similar topics

reply views Thread by plmanikandan | last post: by
5 posts views Thread by Preben Zacho | last post: by
4 posts views Thread by Boni | last post: by
reply views Thread by jack112 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.