服务器端JS和客户端一样用,调用 控件时 和vbscript 唯一区别就是 加()。还有,它一般用 new ActiveXObject 不用 Server.CreateOBject(),也可以用
<@language=JScript> <% var conn=Server.CreateOBject("ADODB.Connection"); var rs=Server.CreateObect("ADODB.Recordset"); conn.open(Application.connectionString); rs.open("select * from dual",conn);.......//the seem as vbscript%>
rsTopTen = new ActiveXObject("ADODB.Recordset"); // ConnectionString Format below: //ConnectionString = "DRIVER=SQL Server;SERVER=MySQLServer;CATALOG=MyDatabase;UID=USERID;PWD=Password"; // // for SQL 7.0: //ConnectionString = "DRIVER=SQL Server;SERVER=TopTen;CATALOG=TopTen;UID=TopTen;PWD=TopTen"; // // for Access Database (on Server): //ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=\\\\demwwwdev01\\develop\\im\\security\\TopTen.mdb"; // // for Access Database (on local drive): ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=C:\\TopTen\\TopTen.mdb"; // Build a SQL statement strSQL = "SELECT TopTenName, TopTenCount FROM TopTen ORDER BY TopTenCount DESC"; // Open the recordset rsTopTen.Open(strSQL, ConnectionString, 3,1,1); // Loop through the Recordset while(!rsTopTen.EOF) {}
javascript是运行在客户端的。如果可以连接数据库的话,那安全隐患可就大了哦……
如果你熟悉javascript的话,编个程序不就可以控制别人的数据库了吗?那还了得?
<%
var conn=Server.CreateOBject("ADODB.Connection");
var rs=Server.CreateObect("ADODB.Recordset");
conn.open(Application.connectionString);
rs.open("select * from dual",conn);.......//the seem as vbscript%>
// ConnectionString Format below:
//ConnectionString = "DRIVER=SQL Server;SERVER=MySQLServer;CATALOG=MyDatabase;UID=USERID;PWD=Password";
//
// for SQL 7.0:
//ConnectionString = "DRIVER=SQL Server;SERVER=TopTen;CATALOG=TopTen;UID=TopTen;PWD=TopTen";
//
// for Access Database (on Server):
//ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=\\\\demwwwdev01\\develop\\im\\security\\TopTen.mdb";
//
// for Access Database (on local drive):
ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=C:\\TopTen\\TopTen.mdb"; // Build a SQL statement
strSQL = "SELECT TopTenName, TopTenCount FROM TopTen ORDER BY TopTenCount DESC"; // Open the recordset
rsTopTen.Open(strSQL, ConnectionString, 3,1,1); // Loop through the Recordset
while(!rsTopTen.EOF)
{}