1

Background: Included so people don't ask Why on earth I am doing this!

I have converted an ancient extremely long winded and complex stored procedure to .NET code as a huge update was required and all functionality was in the stored procedure and was far to complicated to update.

This stored procedure was consumed by classic ASP in multiple places within the website.

Requirement I now need to send the results of this new piece of .NET code back to classic asp as a recordset I intend on doing this by webservice

What I have so Far So far I have worked out that I can actually create a recordset in .NET like so

 ADODB.Recordset rs = new Recordset();

and then return it as an xml string to asp (I have not tested this yet)

rs.Save(streamObj, PersistFormatEnum.adPersistXML);
// Get the string (XML) of the recordset
string outputXml = streamObj.ReadText(str.Size);
return outputXml;

In the asp I will then use this function which I found here in the asp to convert the xml back to a recordset

Public Function RecordsetFromXMLString(sXML As String) As Recordset
    Dim oStream As ADODB.Stream
    Set oStream = New ADODB.Stream
    oStream.Open
    oStream.WriteText sXML   'Give the XML string to the ADO Stream
    oStream.Position = 0    'Set the stream position to the start
    Dim oRecordset As ADODB.Recordset
    Set oRecordset = New ADODB.Recordset
    oRecordset.Open oStream    'Open a recordset from the stream
    oStream.Close
    Set oStream = Nothing
    Set RecordsetFromXMLString = oRecordset  'Return the recordset
    Set oRecordset = Nothing
End Function

The bit that's puzzling me In my .NET I have a generic list that contains all the data that needs to be returned. How do I get this in my recordset?

Bex
  • 4,898
  • 11
  • 50
  • 87

1 Answers1

0

You can checkout below link which explains converting RecordSet to Generic list and do the reverse.

http://app-code.net/wordpress/?p=417

Convert LIst to Datatable .NET - Convert Generic Collection to DataTable

You can Convert DataTable to RecordSet http://www.codeproject.com/Articles/10503/Simplest-code-to-convert-an-ADO-NET-DataTable-to-a

Please check this.

Community
  • 1
  • 1
Ravi Vanapalli
  • 9,805
  • 3
  • 33
  • 43
  • Now that's going to be useful! But it doesn't show how to convert the generic list into a record set! Am I missing something? – Bex Jan 25 '12 at 13:50
  • I'm sorry.. I haven't yet got the recordset! I need to turn my dataset/generic list etc into a record set, not the other way round! I've wroked out that bit now.. will post when have full solution – Bex Jan 25 '12 at 14:49
  • @Bex if this answered then please also up Vote the answer. – Ravi Vanapalli May 28 '12 at 12:07