//用 JavaScript 写服务器端连接数据库的代码示例 var conn = new ActiveXObject("ADODB.Connection"); //var sqlstr="Provider=SQLOLEDB.1; Data Source=localhost; User ID=sa;Password=; Initial Catalog=pubs"; var sqlstr="Provider=Microsoft.Jet.OLEDB.4.0;data Source='jiameng/cn.mdb';UID=sa;PWD=;database=test"; conn.Open(sqlstr); var rs = new ActiveXObject("ADODB.Recordset"); var sql="select top 10 * from staff"; rs.open(sql,conn); shtml = ""; shtml +=""; while(!rs.EOF) { shtml += ""; rs.moveNext; } shtml += "
st_idst_namepassword
" + rs("st_id") + "" + rs("st_name") + "" + rs("password") +"
"; document.write(shtml); rs.close(); rs = null; conn.close(); conn = null;