Skip to content
Advertisement

Using Classic ASP – SQL – JSON

I’m trying to serialize a SQL query in Classic ASP to a json object and I have found some great code that helps me achieve that but where my issue comes in is I then need to manipulate the output that is returned by the QueryToJSON(cmd, arParams).Flush

I need to take the value and add some string / text to it in order for me then to post the returned JSON to API.

I was thinking simply create a variable add the results (QueryToJSON(cmd, arParams).Flush) to that, then I can manipulate / do what I need with it. However you can’t seem to bind QueryToJSON(cmd, arParams).Flush to a variable. It just ignores that, it appears that I can only print the output to screen and do nothing with it. The script is using Microsoft NorthWind sample DB but is easy to adapt to any database/table, I have added a test DB script/data below.

Below is all the source that I have found here https://www.mikesdotnetting.com/article/98/ajax-with-classic-asp-using-jquery and https://code.google.com/archive/p/aspjson/

Using this gets me so close to where I need to be. Any advice would be great, thanks for looking.

Here is the latest JSON_2.0.4.asp

SQL DB/TABLE/SAMPLE DATA

Advertisement

Answer

  1. After start lines

add line

  1. Use set command

  2. Add/Edit some values to/in Variable

( 0 – index of first element of Array. 1 – second… ect

Variable.Count - 1 = last index )

  1. Flush Variable

( Flush is jsCore method )

UPDATE

Replace in your script lines

with this one chunk

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement