使用javascript的sql查询
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了使用javascript的sql查询相关的知识,希望对你有一定的参考价值。
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////////////////////////////////// <head> 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>
以上是关于使用javascript的sql查询的主要内容,如果未能解决你的问题,请参考以下文章