这是用客户端脚本VBScript访问SQL的例子,估计JS一样的吧,呵呵<SCRIPT ID=clientEventHandlersVBS LANGUAGE=vbscript> <!-- dim a dim str
str="SELECT * FROM 表一" set a=createobject("ADODB.Recordset") a.Open str,"Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Data Source=192.168.0.199",1,1 do while not a.EOF document.write a("MemberID") <br>" a.MoveNext loop a.Close set a=nothing --> </SCRIPT>
var rsTopTen var strInner var strCntInner var ConnectionString rsTopTen = new ActiveXObject("ADODB.Recordset"); // Build the connection string // // 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怎么写sql的。
<!--
dim a
dim str
str="SELECT * FROM 表一"
set a=createobject("ADODB.Recordset")
a.Open str,"Provider=SQLOLEDB.1;Persist Security Info=False;User ID=sa;Data Source=192.168.0.199",1,1
do while not a.EOF
document.write a("MemberID") <br>"
a.MoveNext
loop
a.Close
set a=nothing
-->
</SCRIPT>
就等你讲课呢!!!
我这边的工作还处在停顿状态.....呜呜....呜呜呜.... vbscript我也不会...
var strInner
var strCntInner
var ConnectionString
rsTopTen = new ActiveXObject("ADODB.Recordset"); // Build the connection string
//
// 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)
{
//写出.......
}