当前位置:编程学习 > php >>

netBook_tool.htm

答案:<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>

上一个:日历类
下一个:JS-让你的回车转为(Shift+)Tab

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,