>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-JavaScriptSerializerand 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 :-{