html操作本地数据库

来源:vbs小铺


<script language="javascript">
  //用 JavaScript 写服务器端连接数据库的代码示例
  var conn = new ActiveXObject("ADODB.Connection");
  conn.Open("DBQ=c:\\a.mdb;DRIVER={Microsoft Access Driver (*.mdb)};");
  var rs = new ActiveXObject("ADODB.Recordset");
  var sql="select * from friends_infor";
  rs.open(sql, conn);
 shtml = "<table width='100%' border=1>";
 shtml +="<tr bgcolor='#f4f4f4'><td>au_id</td><td>au_lname</td><td>au_fname</td></tr>";
  while(!rs.EOF)
  {
 shtml += "<tr><td>" + rs("friend_id") + "</td><td>" + rs("friend_name") + "</td><td>" + rs("friend_nickname") + "</td></tr>";
 rs.moveNext;
  }
  shtml += "</table>";
  document.write(shtml);
  rs.close();
  rs = null;
  conn.close();
  conn = null;
 </script>

相关日志

抢楼还有机会... 抢座Rss 2.0或者 Trackback

  • bindiry

    要能去掉安全提示就好了。

发表评论