复制代码 代码如下:
//用JavaScript写服务器端连接数据库的代码示例
varconn=newActiveXObject("ADODB.Connection");
conn.Open("DBQ=c:a.mdb;DRIVER={MicrosoftAccessDriver(*.mdb)};");
varrs=newActiveXObject("ADODB.Recordset");
varsql="select*fromfriends_infor";
rs.open(sql,conn);
shtml="
shtml+="au_id au_lname au_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;