SQL query serialization to json file in classic ASP

quickening

New Member
I'm trying to serialize a SQL query in ASP to a json object like this: [["name1","phone1","email1","address1"],["name2","phone2","email2","address2"]]I've made two loops to go through the columns and the rows of the db and this is how i got so far;\[code\]<!--#include file="JSON_2.0.4.asp"-->SQL = "SELECT name, phone, email, address FROM clients"Set Connection = Server.CreateObject("ADODB.Connection")Set Recordset = Server.CreateObject("ADODB.Recordset")Connection.Open "Provider=sqloledb;SERVER=localhost;DATABASE=mydatabase;UID=;PWD=1234;" Recordset.Open SQL,ConnectionrsArray = Recordset.getRows() ReDim arrObj(UBound(rsArray, 2) - 1)Dim i, j For i = 1 To UBound(rsArray, 2) ReDim arrProp(UBound(rsArray, 1)) For j = 0 To UBound(rsArray, 1) arrProp(j) = rsArray(j, i) Next NextResponse.Write toJSON(arrProp)\[/code\]What am i getting wrong here, I've tried to change every value possible.The result gives me just the last row of the table(like the following) of course i would like to retrive every row from the database.Thank you in advance for any possible answer. ["La Musical Fashion","214478457","[email protected]","Av. Quinta Grande, 8 R/C Esq."]
 
Back
Top