Saturday, December 8, 2007

Creating a SQL to JSON Server in ASP.NET

Here's an article I wrote some time ago when I was first exploring Ajax: Creating JavaScript Objects From SQL Queries. There's a VS 2003 project available for download as well. The article demonstrates a way to convert the result set of a SQL SELECT query to JSON, or Javascript Object Notation. JSON is easy for Javascript code to parse and display. Much easier than XML, in my opinion, which is what Ajax applications were originally designed around.

An ASP.NET page, response.aspx, acts as a JSON "server" -- it receives a SELECT query, gets it from the server, translates it into JSON, and returns it. An Ajax-capable HTML page acts as the "client", and uses the JSON object to display data dynamically on the page.

No comments:

Post a Comment