当前位置: 代码迷 >> JavaScript >> javascript连接数据库,该怎么解决
  详细解决方案

javascript连接数据库,该怎么解决

热度:370   发布时间:2013-09-17 13:35:59.0
javascript连接数据库
IE的连接会了

        function connSql() {
            var conn = new window.ActiveXObject("adodb.connection");
            var dr = new window.ActiveXObject("ADODB.Recordset");
            conn.ConnectionString = "Provider=SQLOLEDB.1;User ID=sa;Password=123456;Initial Catalog=ERP;Data Source=.";
            conn.open;
            var sql = "select * from user_info";
            dr.open(sql, conn);
            shtml = "<table width='100%' border=1>";
            shtml += "<tr>";
            for (var i = 0; i < dr.Fields.count; i++) {
                shtml += "<td>" + dr.Fields(i).name + "</td>";
            }
            shtml += "</tr>";

            while (!dr.EOF) {
                shtml += "<tr>";
                for (var i = 0; i < dr.Fields.count; i++) {
                    shtml += "<td>" + dr(dr.Fields(i).name) + "</td>";
                }
                shtml += "</tr>";
                dr.moveNext;
            }
            shtml += "</table>";
            document.write(shtml);
  相关解决方案