How to connect to a Pervasive Database using javascript?

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

Was this solution helpful to you?

Related Q & A:

Just Added Q & A:

Find solution

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.