夜火博客

html操作本地数据库

2008-02-29
技术文章
数据库
脚本Script
1分钟
100字

来源:vbs小铺

1
<script language="javascript">
2
  //用 JavaScript 写服务器端连接数据库的代码示例
3
  var conn = new ActiveXObject("ADODB.Connection");
4
  conn.Open("DBQ=c:\a.mdb;DRIVER={Microsoft Access Driver (*.mdb)};");
5
  var rs = new ActiveXObject("ADODB.Recordset");
6
  var sql="select * from friends_infor";
7
  rs.open(sql, conn);
8
 shtml = "<table width='100%' border=1>";
9
 shtml +="<tr bgcolor='#f4f4f4'><td>au_id</td><td>au_lname</td><td>au_fname</td></tr>";
10
  while(!rs.EOF)
11
  {
12
 shtml += "<tr><td>" + rs("friend_id") + "</td><td>" + rs("friend_name") + "</td><td>" + rs("friend_nickname") + "</td></tr>";
13
 rs.moveNext;
14
  }
15
  shtml += "</table>";
6 collapsed lines
16
  document.write(shtml);
17
  rs.close();
18
  rs = null;
19
  conn.close();
20
  conn = null;
21
 </script>
本文标题:html操作本地数据库
文章作者:夜火
发布时间:2008-02-29