0

I am trying the jQuery datatables and its pretty amazing. What I need to do however is get data from a stored procedure (SQL Server 2012) which accepts a parameter. What are the options here? Do I have to build a web service to get the data or is it possible without creating a service layer?

Also I am unable to find an example that uses SP with parameters? If anyone has an example please share it with me.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
JackSmith
  • 55
  • 8
  • Do I have to build a web service to get the data - Probably, you can't access the DB directly from the client/browser – Alon Eitan Jun 29 '20 at 13:23
  • So how do I pass the parameters to the webservice from AJAX? A querystring parameter for example? – JackSmith Jun 29 '20 at 13:37
  • Not sure I understand, but basically you pass the parameters from the table (filters/sorting/etc...) to your server using ajax, and on the server you perform the DB query with the relevant parameters and then you pass then back to the client. Check [this page](https://datatables.net/examples/ajax/) and [this](https://datatables.net/examples/server_side/) for relevant examples – Alon Eitan Jun 29 '20 at 13:43

1 Answers1

1

No, a web service is not obligatory. Refer: Web service vs Direct connection to DB

If you have control over the SQL server, options of using the JSON/CSV format as acceptable to data-tables is always there. Check Data Sources for Datatables.

Avoid cross-origin error while trying to access local files (maintain directory structure i.e. parent/origin/target file paths). Refer Cross origins and local file access by Firefox

Hope some of it helps