和vbscript类似,只是注意函数的大小写敏感

解决方案 »

  1.   

    啊??可以的阿?
     javascript不是客户端的脚本语言吗? 也能访问数据库?还是有另外的意思?
     学习
      

  2.   

    也有服务端的javascript的,其他脚本语言可以做的事情,server javascript大部分都能做到。
      

  3.   

    net_lover(孟子E章) :
    给讲一讲吧!!在网上搜来搜去,都没看到用javascript怎么写sql的。
      

  4.   

    这是用客户端脚本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>
      

  5.   

    net_lover(孟子E章):
       就等你讲课呢!!!
       我这边的工作还处在停顿状态.....呜呜....呜呜呜....   vbscript我也不会...
      

  6.   

    用ADO连接数据库是通用的,只是语法上有差别,孟子在这里我不敢随便写,恨不得给你写了先,呵呵。
      

  7.   

    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)
    {
             //写出.......
            }