js 连接access数据库
- JScript code
var conn = new ActiveXObject("Adodb.Connection"); var filePath = location.href.substring(0, location.href.indexOf("1.html"));var path = filePath + "guanggao.mdb";path = path.substring(8);document.write(path)conn.Provider = "Microsoft.Jet.oledb.4.0";conn.ConnectionString ="data source="+path;document.write("3")conn.open;document.write("4")var rs = new ActiveXObject("ADODB.Recordset"); rs.open("select * from youxiajiao where zt=0", conn)if(rs.eof) { rs.close(); rs = null; rs = new ActiveXObject("ADODB.Recordset"); conn.execute("update youxiajiao set zt=0"); rs.close(); rs = null; rs = new ActiveXObject("ADODB.Recordset"); rs.open("select * from youxiajiao where zt=0", conn); }var id1=rs.Fields("id");var title1=rs.fields("title");var url1=rs.fields("url");rs.close();rs = null;rs = new ActiveXObject("ADODB.Recordset");conn.execute("update youxiajiao set zt=1 where id="+id1);rs.close();rs = null;conn.close(); conn = null; 执行到 conn.open 就出错 为什么啊
[解决办法]
膜拜下~~我都是用异步到服务器端连接的。。。这样若可以,那效率也不高吧!还有如何保证安全?数据库都暴露了。