js写数据库

<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title></title>
    <meta charset="utf-8" />
    <title>Welcome to myBlog!</title>
    <style>
        body {
            width: 35em;
            margin: 0 auto;
            font-family: Tahoma, Verdana, Arial, sans-serif;
        }
    </style>

    <script language="javascript">

        window.onload = function () {

            var userName = "myBlog";

            insert();
        }

    </script>

    <script language="javascript">
        function insert() {
            var strIp = document.getElementById("ip");
       
            var conn = new ActiveXObject("Adodb.Connection");
            conn.Open("driver={SQL server};database=myDatabase;server=locahost;uid=sa;pwd=xxx")
            var rs = new ActiveXObject("Adodb.Recordset");
            var sql = " INSERT INTO SYS_Log (LogArea,LogPoint,LogTime,UserCode) VALUES('testIp','" + strIp.innerText + "',GETDATE(),'frj');  ";
            rs.open(sql, conn, 3, 2);
        
        }

    </script>

</head>

<body>
    <h1>Welcome to myBlog!</h1>
    <p  id="ip">This is myBlogIp</p>
</body>
</html>

posted @ 2016-04-05 20:50  金虹巴巴  阅读(342)  评论(0编辑  收藏  举报