// Connect to SQL
Copy codeThe Code is as follows:
<Script language = "javascript">
Var conn = new ActiveXObject ("ADODB. Connection ");
Conn. Open ("Provider = SQLOLEDB.1; Data Source = tg; User ID = sa ;"
+ "Password = sasa; Initial Catalog = MyBulletin ");
Var rs = new ActiveXObject ("ADODB. Recordset ");
Var SQL = "select id, name from Category ";
Rs. open (SQL, conn );
Alert (rs (0); // retrieve the first
Rs. close ();
Rs = null;
Conn. close ();
Conn = null;
</Script>
// Connect to ACCESS
Copy codeThe Code is as follows:
<Script language = "javascript">
Function conn (){
Var db_bbs
Db_bbs = "dd. mdb" // defines the database
Var conn = new ActiveXObject ("ADODB. Connection ");
Conn. Open ("Provider = Microsoft. Jet. OLEDB.4.0; Data Source =" + db_bbs + "");
Var rs = new ActiveXObject ("ADODB. Recordset ");
Var SQL = "select name from authors"; // The authors table and name field are in the database.
Rs. open (SQL, conn );
Alert (rs (0) // retrieve the first
Conn. close ();
Conn = null;
}
</Script>