Javascript的Access访问类

来源:互联网 发布:c语言线程 编辑:程序博客网 时间:2024/05/16 12:16
  
var con; var Class = { create: function() {return function() { this.initialize.apply(this, arguments);} }}var DataBase = new Class.create();DataBase.prototype = {initialize: function(filename,datafile) {var filePath = location.href.substring(0, location.href.indexOf(filename));filePath=decodeURI(filePath); var path = filePath + datafile;//去掉字符串中最前面的"files://"这8个字符。path = path.substring(8);//建立连接,并生成相关字符串 www.knowsky.com。con = new ActiveXObject("ADODB.Connection");con.Provider = "Microsoft.Jet.OLEDB.4.0";con.ConnectionString = "Data Source=" + path;con.open();},close:function(){//关闭con.close();con = null;},execute:function(sql){//执行sql不返回con.execute(sql);},openRs:function(sql){//执行sql返回rsvar rs = new ActiveXObject("ADODB.Recordset");rs.open(sql, con);return rs;}}

使用方法:

如在test.html文件中使用

 

原创粉丝点击