//连接SQL 复制代码 代码如下: <br>var conn = new ActiveXObject("ADODB.Connection"); <br>conn.Open("Provider=SQLOLEDB.1; Data Source=tgf; User ID=sa; " <br> "Password=sasa; Initial Catalog=MyBulletin"); <br>var rs = new ActiveXObject("ADODB.Recordset"); <br>var sql="select id,name from Category"; <br>rs.open(sql, conn); <br>alert(rs(0));//取出第一个来 <br>rs.close(); <br>rs = null; <br>conn.close(); <br>conn = null; <br> //连接ACCESS 复制代码 代码如下: <br>function conn(){ <br>var db_bbs <br>db_bbs="dd.mdb"//定义数据库 <br>var conn = new ActiveXObject("ADODB.Connection"); <br>conn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" db_bbs ""); <br>var rs = new ActiveXObject("ADODB.Recordset"); <br>var sql="select name from authors"; //数据库中有authors表,name字段 <br>rs.open(sql,conn); <br>alert(rs(0))//取出第一个来 <br>conn.close(); <br>conn = null; <br>} <br>