复制代码 代码如下:
//用 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 = "
shtml +="
au_idau_lnameau_fname";while(!rs.EOF)
{
shtml += "
" + rs("friend_id") + "" + rs("friend_name") + "" + rs("friend_nickname") + "";rs.moveNext;
}
shtml += "
";document.write(shtml);
rs.close();
rs = null;
conn.close();
conn = null;