Cannot serialize interface ADODB.Recordset

A

Adam Short

When returning an ADO Recordset via Web Services I get the following error:

Cannot serialize interface ADODB.Recordset

Any Ideas?
 
M

Manohar Kamath

Adam,

Return the XML for the recordset, not the recordset itself. The following
example works:

[WebMethod]
public string GetRecordXML()
{
// Create a recordset object
Recordset rs = new Recordset();

// Create a stream object
Stream streamObj = new Stream();


// Query a table for a recordset
rs.Open("SELECT * FROM MyTable",
"dsn=LocalServer;UID=usernamehere;PWD=enter password here",
CursorTypeEnum.adOpenStatic, LockTypeEnum.adLockReadOnly, 1);

// Save the recordset's XML representation in a stream object
rs.Save(streamObj, PersistFormatEnum.adPersistXML);

// Get the string (XML) of the recordset
string outputXml = streamObj.ReadText(str.Size);

return outputXml;
}

When you get the recordset on the client side, you need to re-create it
using Open.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top