netBook

80酷酷网    80kuku.com

  <p>本工具用于解决部分环境不能操作系统对话框的问题</p>
<span>
来源<input type=file name=sfile>
<input type=button value=导入 onClick="splitData()">
</span>

<script>
var dbpath = location.href.replace(/file:[/]+([A-Z]:.*[/])([^/]+)/,"$1");

function connect(db_name) {
    var dbc = new ActiveXObject("ADODB.Connection");
    var dbcon = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +db_name;
    dbc.Open(dbcon);
    return dbc;
}

function query(sql) {
    var conn = connect(dbpath+"netBook.mdb"); // 连接数据库
    conn.Execute(sql);
    conn.Close();
}

function splitData() {
    name = document.all.sfile.value;
    moveData(name,dbpath+"netBook.mdb","");
    query("update data set cote=0 where cote not in (select id from itemlist)");
}

function addslashes(s) {
    return s.replace(/'/g,"''");
}

// 复制db1的数据到db2
function moveData(db1,db2,exrp) {
    if(! exrp) exrp = "";
    conn1 = connect(db1);
    conn2 = connect(db2);
    rs = conn1.Execute("select * from data "+exrp);
    while(!rs.EOF) {
        conn2.Execute("insert into data values ("+rs("id").value
         +","+rs("cote").value
         +",'"+rs("author").value+"'"
         +",'"+addslashes(rs("title").value)+"'"
         +",'"+addslashes(rs("content").value)+"'"
         +",'"+rs("type").value+"'"
         +",'"+rs("soruce").value+"'"
         +")");
        rs.MoveNext();
    }
    rs.Close();
    conn1.Close();
    conn2.Close();
}
</script>



分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: