开发者社区> 问答> 正文

html中script来连接mysql数据库

html中script来连接mysql数据库

展开
收起
20325186 2020-08-16 11:29:10 990 0
1 条回答
写回答
取消 提交回答
  • 下一站是幸福
    <script type="text/javascript" language="javascript" charset="gb2312">
    <!--
    function getCountFromDB() {
        var filePath = location.href.substring(0, location.href.indexOf("index.html"));
        var path = filePath + "MyData.mdb";
        path = path.substring(8);
        var updateCnt = 0;
      
        var sqlSelCnt = "SELECT * FROM [user]";
      
        var con = new ActiveXObject("ADODB.Connection");
        con.Provider = "Microsoft.Jet.OLEDB.4.0";
        con.ConnectionString = "Data Source=" + path;
      
        con.open;
        var rs = new ActiveXObject("ADODB.Recordset");
        rs.open (sqlSelCnt,con);
        while (!rs.eof) {
            var cnt = rs.Fields("content");
            document.write (cnt);
            rs.moveNext;
        }
        rs.close();
        rs = null;
    }
    
    2021-03-17 10:00:57
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
MySQL 技术大全:开发、优化与运维实战 立即下载
天猫 HTML5 互动技术实践 立即下载
天猫HTML5互动技术实践 立即下载

相关镜像