Return recordset using a Web Service
How can I go about returning a recordset in C#? These records are retrieved from SQL server. Web services by default uses XML - I don't w开发者_开发知识库ant this. I want it to return it as a recordset instead. These values will be used by ASP classic.
You can't return a record set. And none of your .NET types will be compatible with classic ASP. You need to read data from the XML only. Understand the XML schema and use Microsoft.XMLDOM
to parse the data.
You're not going to be able to ingest an ASP.NET WebService in Classic ASP through any other method than parsing the XML response.
The following link has some information on how to take advantage of the MS SOAP Toolkit to make this easier for you: https://web.archive.org/web/20210125161040/http://www.4guysfromrolla.com/webtech/070302-1.shtml
SOAP web services return XML. That's the only thing they can return. Period.
(for the nitpickers, yes, WCF can create web services that return JSON or binary, but Classic ASP will have less luck with those than with XML).
You can convert a DataTable
to a ADO Recordset. Here is a link to some code that does that. http://chiragrdarji.blogspot.com/2007/02/converting-dataset-into-recordset.html
I have not tested the code but by the looks of it, it should work.
If you have trouble returning the recordset com
object from your c# app you can convert the recordset to xml using Recordset.Save and specify adPersistXML
http://msdn.microsoft.com/en-us/library/ms681501%28v=VS.85%29.aspx
You will then have the xml string representation of a ado recordset that you can return from your c# app to your classic ASP. Your ASP app should use recordset.Open with the xml as argument to load to recordset. http://msdn.microsoft.com/en-us/library/ms675544%28v=VS.85%29.aspx
Edit 1 Here is the steps you need to take to make this happen.
In the C# web-service
- Connect to the db and fetch the
DataSet
. - Convert the
DataTable
of theDataSet
to aRecordset
. - Convert the
Recordset
to a xml string. - Return the string to the client.
In the client
- Create the
Recordset
object. - Load the
Recordset
with the string returned from the web-service.
ado can use xml as a source.
Microsoft OLE DB Simple Provider
http://msdn.microsoft.com/en-us/library/ms810621
精彩评论