|
 |
aspx thread: ADO recordset consuming a Web Service
Message #1 by "Michael Gaertner" <mgaert@b...> on Fri, 19 Jan 2001 17:44:33 -0500
|
|
My recordset won't consume the XML that is returned from the following web
service:
public class DataService {
[WebMethod]
public DataSet GetTitleAuthors(string ID) {
string selectBP = "SELECT * FROM vw_AllBPs WHERE bpID ='" + ID + "'";
string selectStream = "SELECT * FROM vw_AllStreams WHERE bpID ='" + ID
+ "'";
string selectHowTo = "SELECT * FROM vw_AllHowTos WHERE bpID ='" + ID +
"'";
ADOConnection myConnection = new
ADOConnection("Provider=SQLOLEDB.1;Persist Security Info=False;User
ID=sa;Initial Catalog=BPTMsql;Data Source=chet");
ADODataSetCommand myCommand1 = new ADODataSetCommand(selectBP,
myConnection);
ADODataSetCommand myCommand2 = new ADODataSetCommand(selectStream,
myConnection);
ADODataSetCommand myCommand3 = new ADODataSetCommand(selectHowTo,
myConnection);
DataSet ds = new DataSet();
myCommand1.FillDataSet(ds, "BrownPaper");
myCommand2.FillDataSet(ds, "Stream");
myCommand3.FillDataSet(ds, "HowTo");
return ds;
}
}
My VBA code:
Sub test()
Dim xmlBPs As MSXML2.DOMDocument30
Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
Set xmlBPs = New MSXML2.DOMDocument30
sURL
"http://localhost/BPdev/experimental/DataService.asmx/GetTitleAuthors?ID=1"
With xmlBPs
.async = False
If .Load(sURL) Then
Set rs = XMLtoADORecordset(.xml)
End If
End With
Do Until rs.EOF
Debug.Print rs!Title
rs.MoveNext
Loop
End Sub
Function XMLtoADORecordset(xml As String) As Recordset
' build an ADO recordset from an XML string
On Error Resume Next
Dim rs As New ADODB.Recordset
Dim st As New ADODB.Stream
st.Open
st.WriteText xml
st.Position = 0
rs.Open st 'THIS LINE BOMBS
If Err.Number <> 0 Then
Debug.Print Err.Number & ":" & Err.Description
Exit Function
End If
Set XMLtoADORecordset = rs
End Function
The Debug.Print is -2147467259:Recordset cannot be created. Source XML is
incomplete or invalid.
Is this because the web service is not returning XML with the correct schema
for the ADODB.Recordset? I tried this with the Sql namespace, same problem.
Thanks.
Michael
Message #2 by "Jonathan Goodyear" <jon@a...> on Sat, 20 Jan 2001 09:49:27 -0500
|
|
I don't think that the XML generated by a DataSet is in the same form as
that of an ADODB.Recordset...In fact, I'm almost positive it isn't...You're
trying to fit a square peg into a round hole...
----jonathan goodyear, mcsd, mcp, cls
The original "angryCoder" (watch for the upcoming launch of angryCoder.com)
president@a...
----- Original Message -----
From: "Michael Gaertner" <mgaert@b...>
To: "ASP+" <aspx@p...>
Sent: Friday, January 19, 2001 5:44 PM
Subject: [aspx] ADO recordset consuming a Web Service
> My recordset won't consume the XML that is returned from the following web
> service:
>
> public class DataService {
>
> [WebMethod]
> public DataSet GetTitleAuthors(string ID) {
>
> string selectBP = "SELECT * FROM vw_AllBPs WHERE bpID ='" + ID + "'";
> string selectStream = "SELECT * FROM vw_AllStreams WHERE bpID ='" + ID
> + "'";
> string selectHowTo = "SELECT * FROM vw_AllHowTos WHERE bpID ='" + ID +
> "'";
>
> ADOConnection myConnection = new
> ADOConnection("Provider=SQLOLEDB.1;Persist Security Info=False;User
> ID=sa;Initial Catalog=BPTMsql;Data Source=chet");
> ADODataSetCommand myCommand1 = new ADODataSetCommand(selectBP,
> myConnection);
> ADODataSetCommand myCommand2 = new ADODataSetCommand(selectStream,
> myConnection);
> ADODataSetCommand myCommand3 = new ADODataSetCommand(selectHowTo,
> myConnection);
>
> DataSet ds = new DataSet();
> myCommand1.FillDataSet(ds, "BrownPaper");
> myCommand2.FillDataSet(ds, "Stream");
> myCommand3.FillDataSet(ds, "HowTo");
>
> return ds;
> }
> }
>
> My VBA code:
>
> Sub test()
> Dim xmlBPs As MSXML2.DOMDocument30
> Dim rs As ADODB.Recordset
>
> Set rs = New ADODB.Recordset
> Set xmlBPs = New MSXML2.DOMDocument30
> sURL
>
"http://localhost/BPdev/experimental/DataService.asmx/GetTitleAuthors?ID=1"
> With xmlBPs
> .async = False
> If .Load(sURL) Then
> Set rs = XMLtoADORecordset(.xml)
> End If
> End With
>
> Do Until rs.EOF
> Debug.Print rs!Title
> rs.MoveNext
> Loop
>
> End Sub
>
> Function XMLtoADORecordset(xml As String) As Recordset
> ' build an ADO recordset from an XML string
> On Error Resume Next
>
> Dim rs As New ADODB.Recordset
> Dim st As New ADODB.Stream
>
> st.Open
> st.WriteText xml
> st.Position = 0
> rs.Open st 'THIS LINE BOMBS
>
> If Err.Number <> 0 Then
> Debug.Print Err.Number & ":" & Err.Description
> Exit Function
> End If
>
> Set XMLtoADORecordset = rs
> End Function
>
> The Debug.Print is -2147467259:Recordset cannot be created. Source XML is
> incomplete or invalid.
>
> Is this because the web service is not returning XML with the correct
schema
> for the ADODB.Recordset? I tried this with the Sql namespace, same
problem.
>
> Thanks.
>
> Michael
>
>
|
|
 |