MS Access(2013)数据库具有下表ImportFromExcel(16列)。我只是想在浏览器中看到该表。任何帮助表示赞赏:)
<html>
<head>
<title>Import From Excel</title>
<script type="text/javascript">
function query()
{
var pad = "C:\\Users\\azi!z\\Desktop\\Project\\Test.accdb";
var cn = new ActiveXObject("ADODB.Connection");
var strConn = "Provider=microsoft.ace.oledb.12.0;Data Source=" + pad;
cn.Open(strConn);
var rs = new ActiveXObject("ADODB.Recordset");
var SQL = "SELECT * FROM ImportFromExcel";
rs.Open(SQL, cn);
if(!rs.bof)
{
rs.MoveFirst();
if(!rs.eof)
{
document.write("<p>" + rs.fields(1).value + ", ");
document.write(rs.fields(2).value + ", ");
document.write(rs.fields(3).value + ".</p>");
}
}
else
{
document.write("No data found");
}
rs.Close();
cn.Close();
}
</script>
</head>
</html>
答案 0 :(得分:0)
您的代码中似乎有拼写错误
文件路径中的 desktop
var pad = "C:\\Users\\azi!z\\esktop\\Project\\Test.accdb";
如果这不是问题,那么请更新您的问题并描述问题,而不仅仅是目标。
您似乎没有调用head
使用下面的代码不在函数中或调用您声明的函数。
请使用此代码,
<html>
<head>
<title>Access db Connection</title>
<script type="text/javascript">
var pad = "C:\\Users\\azi!z\\Desktop\\Project\\Test.accdb";
//var strConn = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + pad;
var strConn = "Provider=microsoft.ace.oledb.12.0;Data Source=" + pad;
var cn = new ActiveXObject("ADODB.Connection");
cn.Open(strConn);
var rs = new ActiveXObject("ADODB.Recordset");
// var SQL = "SELECT * FROM customer_mas WHERE ID='512225'";
var SQL = "SELECT * FROM ImportFromExcel";
rs.Open(SQL, cn);
if(!rs.bof) {
rs.MoveFirst();
if(!rs.eof) {
document.write("<p><br>" + rs.fields(1).value + ", ");
document.write("<br>" + rs.fields(2).value + ", ");
document.write("<br>" + rs.fields(3).value + ".</p>");
}
}
else {
document.write("No data found");
};
rs.Close();
cn.Close();
</script>
</head>
</html>