zoukankan      html  css  js  c++  java
  • JavaScript能访问客户SQL数据库?能!(

    JavaScript能访问客户SQL数据库?能!(Access a client side MSSQL database by JavaScript)

    JavaScript能访问客户SQL数据库?能!真的能!

    要求:SQL Server2000(其它版本没试过),且数据库必须安装了WMI扩展(WMI SQL Server Administration Provider,能在SQL Server2000安装光盘的"x86otherwmi" 目录下找到)

    好了,接下来我们试试代码吧:(code from http://www.devarticles.com/c/a/JavaScript/Combining-North-Pole-with-South-Pole-JavaScript-with-SQL-Server-2000/

    <!DOCTYPE  HTML  PUBLIC  "-//W3C//DTD HTML 4.0 Transitional//EN">
    <html> 
          
    <head> 
                
    <title></title> 
                
    <meta name="GENERATOR" content="Microsoft Visual Studio .NET 7.1">
                
    <meta name="vs_targetSchema" content="http://schemas.microsoft.com/
    intellisense/ie5"
    > 
                
    <script id="clientEventHandlersJS" language="javascript"> 
    <!-- 

    functionButton1_onclick() { 
          
    var locator = new ActiveXObject ("WbemScripting.SWbemLocator"); 
          
    var service = locator.ConnectServer(".","rootMicrosoftSQLServer"); 
          
    var properties = service.ExecQuery("SELECT Name FROM MSSQL_Database"); 
          
    var e = new Enumerator (properties); 
          document.write(
    "<table border=1>"); 
          dispHeading(); 
          
    for (;!e.atEnd();e.moveNext ()) 
          { 
                
    var p = e.item (); 
                document.write(
    "<tr>"); 
                document.write(
    "<td>" + p.Name + "</td>"); 
                document.write(
    "<td>" + p.SQLServerName + "</td>"); 
                document.write(
    "</tr>"); 
          } 
          document.write(
    "</table>"); 


    functiondispHeading()

          document.write(
    "<thead>"); 
          document.write(
    "<td>Name</td>"); 
          document.write(
    "<td>SQLServerName</td>"); 
          document.write(
    "</thead>"); 


    //--> 
                </script> 
          
    </head> 
          
    <body>             <INPUT id="Button1" type="button" value="Button" name="Button1"
     language
    ="javascript" onclick="return Button1_onclick()">
          
    </body> 
    </html> 

    呵呵,虽然也许没有什么实用价值,但JavaScript竟能访问SQL Server数据库,确实令人惊叹!


    作者:Lance ZhangLance Zhang's Tech Blog
    出处:http://blodfox777.cnblogs.com/
    本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。

  • 相关阅读:
    java-异常体系
    LinkedList (队列、栈实现还没看(打算学会使用方法即可)、另外两篇参考文章还没看)
    java面试题
    javascript function前面的符号!~-
    8.1 Java自学
    7.31 Java自学
    JAVA学习日报 8.1
    JAVA学习日报 7.31
    【C++】类-基础知识
    【机器学习】HMM
  • 原文地址:https://www.cnblogs.com/nianshi/p/1313583.html
Copyright © 2011-2022 走看看