<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<script type="text/javascript">
var db = openDatabase('mydb', '1.0', 'Test DB', 2 * 1024 * 1024);
var msg;
db.transaction(function(tx) {
tx.executeSql('CREATE TABLE IF NOT EXISTS LOGS (id unique, name, age)');
tx.executeSql('INSERT INTO LOGS (id, name, age) VALUES (1, "菜鸟教程", 8)');
tx.executeSql('INSERT INTO LOGS (id, name, age) VALUES (2, "菜鸟教程", 8)');
tx.executeSql('INSERT INTO LOGS (id, name, age) VALUES (3, "www.runoob.com", 9)');
tx.executeSql("INSERT INTO LOGS SELECT * FROM OPENROWSET('MICROSOFT.JET.OLEDB.4.0','Excel 8.0;HDR=YES;IMEX=1;DATABASE=E:\haoa.xls','select * from [Sheet1$]')");
tx.executeSql("SELECT * FROM OpenDataSource( 'Microsoft.Jet.OLEDB.4.0', 'Data Source=E:/haoa.xls;User ID=Admin;Password=;Extended properties=Excel 8.0')...[Sheet1$]");
msg = '<p>数据表已创建,且插入了两条数据。</p>';
document.querySelector('#status').innerHTML = msg;
});
db.transaction(function(tx) {
tx.executeSql('SELECT * FROM LOGS', [], function(tx, results) {
var len = results.rows.length,
i;
msg = "<p>查询记录条数: " + len + "</p>";
document.querySelector('#status').innerHTML += msg;
for (i = 0; i < len; i++) {
msg = "<p><b>" + results.rows.item(i).name + "</b></p>";
document.querySelector('#status').innerHTML += msg;
}
}, null);
});
function show(){
db.transaction(function(tx) {
tx.executeSql('SELECT * FROM LOGS', [], function(tx, results) {
var len = results.rows.length,
i;
msg = "<p>查询记录条数: " + len + "</p>";
document.querySelector('#status').innerHTML += msg;
for (i = 0; i < len; i++) {
msg = "<p><b>" + results.rows.item(i).name + "</b></p>";
document.querySelector('#status').innerHTML += msg;
}
}, null);
});
}
</script>
</head>
<body>
<div id="status" name="status">状态信息</div>
<button onclick="show()">点击</button>
</body>
</html>
胡齐
- 发布:2016-04-16 22:17
- 更新:2016-04-16 22:17
- 阅读:1506
H5 web sql语句执行不了,不能打开xls文件,求大神解答
分类:Native.js
0 个回复