I made a database that holds information about clinical trials and so far I have been accessing and writing to it using php. I was wondering if there was a way to read/write to a SQL Server database using javascript or jquery? The UI I am developing will be for adding clinical trial data to the database. Only the DB admins will have access to this UI so security should not be a "huge" problem.
Asked
Active
Viewed 183 times
-3
-
You can't (without browser extensions/plugins) write directly (to a server database) with JavaScript so it's an **invalid** idea *as believed*. If you use JavaScript to access the server, then you're really just accessing an exposed Web API (e.g. PHP or whatever). Considering that the Web API acts as a DAL (or can more uniformly expose the required actions), I would not directly use JavaScript (through a plugin) nor would I query the database directly through even a thin wrapper.. – user2864740 May 15 '14 at 20:05
3 Answers
2
You need a middle tier like php, rails, java... to do the database write. You can't do this from the browser with javascript. But there is Node.js, which allows you do write javascript on the server.

Davide Pastore
- 8,678
- 10
- 39
- 53

Alex Shilman
- 1,547
- 1
- 11
- 15
0
In short, no. Even if there was, you should never leave data validation to the client. Just because your DB Admins are trustworthy, doesn't mean those who break into your network will be. DROP TABLE ClinicalTrialData; would be a bad thing. Use PHP/backend of choice to do the donkeywork and use AJA[X|J] if you want a slick UI experience.

Lee S
- 343
- 1
- 8
-
Someone doesn't like the answers given... I'd comment to @Alex Shilman, but the last downvote took me to under 50 so I can't lol – Lee S May 15 '14 at 19:58
0
Only server side Javascript methods such as using NodeJS as your server. Never put your database credentials on the front end unless you want people to directly access your database.

Jack Shultz
- 2,031
- 2
- 30
- 53