Not able to get data from the database: 500 Internal Server Error

Not able to get data from the database: 500 Internal Server Error

sbjasonsbjason Posts: 3Questions: 1Answers: 0

I am not able to pull data from the SQL database when I use the following code.

<

script>
var Popup, dataTable;
$(document).ready(function () {
dataTable = $('#MTRTable').DataTable({
"ajax": {
"url": "/Tag/GetData",
"type": "GET",
"datatype": "json"
},
"columns": [
{ "data": "Tag" },
{ "data": "Service Description" },
{ "data": "Drawing" },
{ "data": "Tag Type" },
],
"language": {
"emptyTable": "No data found, Please check the data sources"
}
});

        });

I am new to coding. Any help is appreciated

Answers

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947

    That error comes from your server. You will need to look at your server logs to see why the server is returning the 500 Internal Server error.

    Kevin

  • sbjasonsbjason Posts: 3Questions: 1Answers: 0

    Kevin,
    Thank you for the response.
    It appears that I have more than 20K rows in the SQL database that the code is trying to convert and present. The app I am developing is to manage large data. around 100K + rows. Any recommendation on how to query the large data without getting 500 errors?
    I am currently using this code to get 2000 records but it won't meet the requirement.

        // GET: Tag
        public ActionResult Index()
        {
            return View();
        }
            public ActionResult GetData(string search = "", int pgNumber = 1, int pgSize = 2000)
            {
                using (FLRTag db = new FLRTag())
                {
                var tags = db.MTRs;
                //.Where((row) => row.Tag.ToLower().Contains(search.ToLower()) || search != "");
                  var tagList = tags
                    .OrderBy(item => item.Tag)
                    .Skip((pgNumber - 1) * pgSize)
                    .Take(pgSize)
                    .ToList<MTR>();
                  return Json(new { data = tagList }, JsonRequestBehavior.AllowGet);
                }
            }
    }
    

    }

  • sbjasonsbjason Posts: 3Questions: 1Answers: 0

    It's working now. Not sure what I did but I bumped the limit to 100K and I am still getting the results. But getting other errors.

    DataTables warning: table id=MTRTable - Requested unknown parameter 'Service Description' for row 0, column 1. For more information about this error, please see http://datatables.net/tn/4

    The service description property in the source table has data.

    Thanks.

  • kthorngrenkthorngren Posts: 21,303Questions: 26Answers: 4,947

    Did you follow the troubleshooting steps listed in the technote http://datatables.net/tn/4 ?

    What is in your JSON response?

    Do you have an object property named Service Description?

    Is your JSON response contained in a data propery?

    Maybe you can post a screenshot with the first row expanded.

    Take a look at the Ajax docs to make sure your response matches a Datatables supported structure.

    Kevin

This discussion has been closed.