Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Return multiple tables to AJAX call
Message
From
06/08/2014 14:22:48
 
 
To
06/08/2014 11:39:03
General information
Forum:
ASP.NET
Category:
AJAX
Environment versions
Environment:
VB 9.0
OS:
Windows Server 2012
Network:
Windows 2008 Server
Database:
MS SQL Server
Application:
Web
Miscellaneous
Thread ID:
01605232
Message ID:
01605244
Views:
43
>Hi all
>
>I need to return two data tables from a stored proc via an AJAX call, but it's giving me an "Internal Server Error" on the return to the AJAX call
>
>AJAX Call:
>
>    function grid_update()
>    {
>        $.ajax({
>            type: 'POST',
>            dataType: 'json',
>            contentType: 'application/json',
>            url: 'HeartBeat.aspx/UpdateGridData'
>        })
>        .done(function (response) {
>            SetGrids(response.d);
>        })
>        .fail(function(){
>        alert("Grid Update Error: " + arguments[2]);
>                });
>      }
>
>
>The WebMethod being called:
>
>       [WebMethod]
>        public static DataSet UpdateGridData()
>        {
>            cSettings cSet = GetSettings();
>            //ExecuteDataset(string commandText, string ConnectionName)
>            DataSet ds1 = new DataSet();
>            string SPCommand = "exec HFCJobLog.dbo.GetHBData 'all', ' " + cSet.TimeStart.ToString() + "', " + cSet.TimeSlice.ToString();
>            ds1 = BLL.cJobs.GetHBData(SPCommand);
>            return ds1;
>        }
>
>
>Could someone please 'splain to me (in words of one syllable preferably) how I need to go about this?

You really should not try to return a dataset (or, come to that, even a datatable) as such.
I see Rick has posted a converter at http://weblog.west-wind.com/posts/2008/Sep/03/DataTable-JSON-Serialization-in-JSONNET-and-JavaScriptSerializer
and you can google other examples.
But if possible use an ORM (e.g.EF or nHibernate) so that the results are available as a simple object hierarchy which will automatically convert to JSON.

Sorry, looks like the only one syllable words are acronyms :-{
Previous
Reply
Map
View

Click here to load this message in the networking platform