朋友,你应该直接找孟老师呀!他就告诉了我一个javascript连接到mssql数据库的方法,不过我也不敢给你传载,因为侵权!不过你可以去:
http://www.csdn.net/expert/topic/1025/1025439.xml?temp=.5482752

解决方案 »

  1.   

    <html>
    <body>
    <h2>表格显示数据表记录</h2>
    <hr>
    <script language="JavaScript">
    // 创建数据库对象
    var objdbConn = new ActiveXObject("ADODB.Connection");
    // DSN字符串
    var strdsn = "Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;User ID=sa;Initial Catalog=INFORMFLAT;Data Source=BARCODE";
    // 打开数据源
    objdbConn.Open(strdsn);
    // 执行SQL的数据库查询
    var objrs = objdbConn.Execute("SELECT VPosition,Item_Sequence,Item_Code FROM D_Manufacture_Current where VPosition < 5");
    // 获取字段数目
    var fdCount = objrs.Fields.Count - 1;
    // 检查是否有记录 
    if (!objrs.EOF){
      document.write("<table border=1><tr>");   
      // 显示数据库的字段名称
      for (var i=0; i <= fdCount; i++)
          document.write("<td><b>" + objrs.Fields(i).Name + "</b></td>");
      document.write("</tr>");
      // 显示数据库内容
      while (!objrs.EOF){
        document.write("<tr>");     
        // 显示每笔记录的字段
        for (i=0; i <= fdCount; i++)
           document.write("<td valign='top'>" + objrs.Fields(i).Value + "</td>");
        document.write("</tr>");
        objrs.moveNext();  // 移到下一笔记录
      }
      document.write("</table>"); 
    }
    else 
      document.write("数据库内没有记录!<br>");
    objrs.Close();        // 关闭记录集合
    objdbConn.Close();    // 关闭数据库链接
    </script>
    </body>
    </html>
      

  2.   

    rsTopTen = new ActiveXObject("ADODB.Recordset");
    ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=C:\\TopTen\\TopTen.mdb";
    strSQL = "SELECT TopTenName, TopTenCount FROM TopTen ORDER BY TopTenCount DESC";
    rsTopTen.Open(strSQL, ConnectionString, 3,1,1);// Set variable
    var nCounter
    nCounter = 0;// Loop through the Recordset
    while(!rsTopTen.EOF)
    { var nCount, strCount, strFormated // Iterate the counter
    nCounter++;

    // Load variables from the Recordset
    strName = rsTopTen.Fields.Item(0).Value;
    nCount = rsTopTen.Fields.Item(1).Value; // Go to the next Record
    rsTopTen.MoveNext();};

    // Close the Recordset
    rsTopTen.Close();
      

  3.   

    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";
    //
    // Build a SQL statement
    strSQL = "SELECT TopTenName, TopTenCount FROM TopTen ORDER BY TopTenCount DESC";// Open the recordset
    rsTopTen.Open(strSQL, ConnectionString, 3,1,1);
      

  4.   

    var ConnectionString
    // Create the Recordset Object
    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);// Set variable
    var nCounter
    nCounter = 0;// Loop through the Recordset
    while(!rsTopTen.EOF)
    {
    ....
    }
      

  5.   

    在Java中连数据库与VB相类似,只是事前声明好了。