How to connect to a database using javascript
-
Can we connect to a database(Oracle,SQL Server) using javascript. If yes please provide me with an example. Thanks in advace
-
Answer:
Actually, yes you can! Not to contradict all comments saying you can't but it depends on which rights you allow the client through ActiveX and ADODB. Example: function dblookup() { var myConnect = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=d:\\sdi.mdb"; var ConnectObj = Server.CreateObject("ADODB.Connection"); var RS = Server.CreateObject("ADODB.Recordset"); var sql="SELECT * FROM employeespulled WHERE empid='1';"; ConnectObj.Open (myConnect); RS.Open(sql,ConnectObj,adOpenForwardOnly,adLockReadOnly,adCmdText); var fieldCount = RS.Fields.Count; Response.Write ("Field Count" + fieldCount); RS.Close(); ConnectObj.Close(); } As this is an "old" way of doing things, I only recommend this in a private environment (intranet) as the security risk is pretty big. In the modern era you would configure a webservice on the server which takes a few parameters and sends a callback function to the client. That way you take the security risk to the server and not to the client.
user2862430 at Stack Overflow Visit the source
Related Q & A:
- How to connect Sql Server Database from android app?Best solution by Stack Overflow
- How to uninstall Firefox add-on using javascript?Best solution by Stack Overflow
- How to connect Laptop to TV using VGA?Best solution by Yahoo! Answers
- How to connect to the internet using Linux?Best solution by Server Fault
- How to connect to a wireless internet connection using my PC?Best solution by Yahoo! Answers
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.