複製程式碼 程式碼如下: //連線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, connrs.open(sql, connrs.open( );<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_ s="dd.mdb"//定義資料庫< //定義資料庫= new ActiveXObject("ADODB.Connection"); <BR>conn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" db_bbs ""); <BR><BR>var rs = new ActiveXObject( "ADODB.Recordset"); var sql="select name from authors"; //資料庫中有authors表,name欄位<P>rs.open(sql,conn);<BR> alert(rs(0 ))//取出第一個來<BR> <BR>conn.close(); conn = null; <P>}