解决部分环境不能操作系统对话框的问题
时间:2007-02-17 来源:PHP爱好者
<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>
php爱好者站 http://www.phpfans.net php动态|php基础|php进阶|php模板.