I'm trying to return the results of a SQL query to a RESTFUL endpoint. I'm unsure of how to convert the results of the query into a JSON object. In SQL 2016 there is a 'USING JSON' feature to do the conversion for you. However in some cases we don't have SQL 2016. What is the most efficient way of converting to JSON? I've done some research and it looks like JavaScriptSerializer is recommended. However I'm unfamiliar with the distinctions between my object type structure of a Recordset vs a Datatable.
using ADODB;
Object SQL = new Object();
ADODB.Recordset rs = new Recordset();
SQL.ExecRecordSet("Select * from table", ref rs);
while (rs.EOF == false)
{
foreach (ADODB.Field field in rs.Fields)
{
if (field.Value != null)
{
Debug.Print(field.Name.ToString());
Debug.Print(field.Value.ToString());
}
}
rs.MoveNext();
}