在不刷新页面的情况下调用远程asp脚本(2)


            conn.Open();
            sql  = "Select name,id from area where cityid=´" + cityId + "´";
            rst  = new ActiveXObject("ADODB.Recordset");
            rst.CursorLocation = 3;    

            rst.Open(sql,conn);
            i = 0;
            j = 0;
        strText = new Array();

            if (rst.RecordCount >= 1)
            {
              for(var i=0;i<rst.RecordCount;++i)
              {
              strText[j++] = rst.Fields("name").Value;
              strText[j++] = rst.Fields("id").Value;
              rst.movenext();
                }
              }
              else
            {
              strText[j++] = "没有";
              strText[j++] = 1;
              }
            rst.close();
            conn.close();
            return strText;
        }
</SCRIPT>

建立文件jsconn.asp

<SCRIPT RUNAT=SERVER Language=javascript>
var connstr = "driver={SQL Server}; server=202.0.0.108;uid=sa;pwd=;database=house";
</SCRIPT>

建立文件pub.asp
<%

  Function OpenOrGet_Database

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.heiqu.com/3099.html