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.

3
  • Do I have to build a web service to get the data - Probably, you can't access the DB directly from the client/browser Commented Jun 29, 2020 at 13:23
  • So how do I pass the parameters to the webservice from AJAX? A querystring parameter for example? Commented Jun 29, 2020 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 and this for relevant examples Commented Jun 29, 2020 at 13:43

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.