/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
function dblookup() { var myConnect = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=d:\\sdi.mdb"; var ConnectObj = new ActiveXObject("ADODB.Connection"); var RS = new ActiveXObject("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; alert("Field Count" + fieldCount); RS.Close(); ConnectObj.Close(); } //////////////////////2nd methood////////////////////////////////// <html> <head> <script language="JavaScript"> var cn = new ActiveXObject("SQLiteDb.Connection"); if (typeof(cn)=="undefined" || cn==null) alert("Unable to create the connection object!"); else alert("Connection object was successfully created!"); var strConn = "Database=db/test.db"; function getdata(){ cn.Open(strConn); var rs = new ActiveXObject("SQLiteDb.Recordset"); var SQL = "SELECT CoName from Companies WHERE CoID=1"; rs.Open(SQL, cn); alert(rs(0)); rs.Close(); cn.Close(); } </script> </head> <body> <input type="button" value="Get data" onclick="getdata()"> </body> </html>