回 帖 发 新 帖 刷新版面

主题:谢谢!大侠帮帮忙看看那里有错

<%@ LANGUAGE="VBScript" %>
<html>
<head>
<script language="VBScript">
<!--
   Sub query_OnClick
      Dim msg
      msg = ""
      
      If dlcx.mc.value = "" Then
         msg = "单位名称不能为空"
         dlcx.mc.focus
      
      ElseIf dlcx.sx.value = "" Then
         msg = "表点属性不能为空"
         dlcx.sx.focus
      End If
      ElseIf dlcx.rq.value = "" Then
         msg = "日期不能为空"
         dlcx.rq.focus
      End If

      If msg = "" Then
         dlcx.submit
      Else
         Alert(msg)
      End If
   End Sub

   Sub reset_OnClick
      dlcx.mc.value = ""
      dlcx.sx.value = ""
      dlcx.stid.focus
   End Sub
-->
</script>
</head>
<body bgcolor="#99CCCC" onLoad="reset_OnClick">
<center>
<font size="6" color="red" face="楷体_GB2312"><b>电量查询网页</b></font>
<marquee bgcolor="aaaaee" behavior="alternate" scrollamount="2">
<font color="yellow" face="楷体_GB2312">欢迎使用电量查询网页!</font>
</marquee>
<form action="dlcxxs.asp" method="post" name="dlcx" target="result" id="dlcx">
<table id="dlcx">
<tr><td colspan="8"><font color="blue">查询条件</font></td></tr>
<tr><td colspan="8"><hr></td></tr>
<tr>
  <td>单位名称</td>
  <td><select name="dwmc">
<%
' 注释:创建并打开Recordset对象
   Set objRS = Session("objRS")
   objRS.Source = "SELECT id, title FROM dwmc"
   objRS.Open 
' 注释:读取记录集中所有的课程记录
   Do While Not objRS.EOF
%>
      <option value=<% = objRS("id") %><% = objRS("title") %>><% = objRS("title") %></option>
<%
      objRS.MoveNext
   Loop
'  注释:关闭记录集
   objRS.Close
   Set objRS = Nothing
%>
   </select>  </td>
   <td>表点属性</td>
   <td><select name="bdsx">
<%
' 注释:创建并打开Recordset对象
   Set objRS = Session("objRS")
   objRS.Source = "SELECT id, title FROM bdsx"
   objRS.Open
' 注释:读取记录集中所有的课程记录
   Do While Not objRS.EOF
%>
      <option value=<% = objRS("id") %><% = objRS("title") %>><% = objRS("title") %></option>
<%
      objRS.MoveNext
   Loop
'  注释:关闭记录集
   objRS.Close
   Set objRS = Nothing
%>
   </select>     &nbsp;</td>
   <td>日期</td>
   <td><input type="text" name="rq" id="rq">     
     &nbsp;</td>
   <td><input name="query" type="button" value="查询">&nbsp;</td>
   <td><input name="reset" type="button" value="重设"></td>
<tr><td colspan="8"><hr></td></tr>
<tr><td colspan="8"><font color="blue">查询结果</font></td></tr>
</table>
</form>
</center>
</body>
</html>

回复列表 (共3个回复)

沙发


把你的出错提示发一下!

板凳


错误类型:
Microsoft VBScript 运行时错误 (0x800A01A8)
缺少对象: '[undefined]'
/yjy/dlcx3.asp, 第 54 行

3 楼


我定义了一个global.asa 内容如下:
script language="VBScript" runat="Server" >
' 注释:定义Session对象的开始过程,用于数据库连接
    Sub Session_OnStart
    ' 注释:数据库连接代码
       Set Session("objConn") = Server.CreateObject("ADODB.Connection")
       Driver = "Driver={Microsoft Access Driver (*.mdb)};" 
       DBPath = "DBQ=" & Server.MapPath("dlgl.mdb")
       Session("objConn").Open Driver & DBPath
    ' 注释:创建Recordset对象
       Set Session("objRS") = Server.CreateObject("ADODB.Recordset")
       Session("objRS").ActiveConnection = Session("objConn")
       Session("objRS").CursorType = 3
    End Sub
' 注释:定义Session对象的结束过程,用于断开数据库连接
    Sub Session_OnEnd
       Session("objRS").Close
       Set Session("objRS") = Nothing
       Session("objConn").Close
       Set Session("objConn") = Nothing
    End Sub
</script>

我来回复

您尚未登录,请登录后再回复。点此登录或注册