主题:  有问题,请前辈指点一下!

计算器

职务:普通成员
等级:1
金币:0.0
发贴:74
注册:2003/6/19 18:21:41
#12004/2/13 16:39:24
<!--#include file="conn.asp" -->
<%
   if not isEmpty(request.QueryString("id")) then
	id=request.QueryString("id")
   else
	id=1
   end if


Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "Select * From sppnews where id="&id, conn,3,3
rs("counter")=rs("counter")+1
rs.update
nCounter=rs("counter")
rs.close
%>

<%
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open "Select * From sppnews where id="&id, conn,3,3
%>

<html>
<head>
<title><%=title%></title>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" href="images/spp.css" type="text/css">
<style type="text/css">
<!--
.1 {
	border: 1px dotted #666666;
}
-->
</style>
</head>

<body bgcolor="#FFFFFF" text="#000000">
<table width="74%" border="0" cellspacing="0" cellpadding="3" align="center">
  <tr> 
    <td> 
      <div align="center"><font color=red>标题:</font><%=rs("title")%></div>
    </td>
  </tr>
  <tr> 
    <td> 
      <hr width="86%" size="1" color="#660000">
    </td>
  </tr>
  <tr> 
    <td> 
      <div align="center">日期:<font size="-2"><%=rs("time")%> </font> 该新闻已被阅读 <%=rs("counter")%> 
        次</div>
    </td>
  </tr>
  <tr> 
    <td height="41"> 
      <table width="400" border="0" align="center" cellpadding="0" cellspacing="0">
        <tr> 
          <td width="2" height="6" background="image/left_1.gif"></td>
          <td width="407"  height="6" background="image/center_1.gif"></td>
          <td width="2" height="6" background="image/right_1.gif"></td>
        </tr>
        <tr> 
          <td width="4" height="6" background="image/left_2.gif"></td>
          <td><br>
            <%=rs("content")%><br>
          </td>
          <td width="4" background="image/right_2.gif"></td>
        </tr>
        <tr> 
          <td width="4" height="6" background="image/left_3.gif"></td>
          <td width="2" height="6" background="image/center_3.gif"></td>
          <td width="4" height="6" background="image/right_3.gif"></td>
        </tr>
      </table></td>
  </tr>
  <tr> 
    <td> <hr width="86%" size="1" color="#660000"> </td>
  </tr>
  <tr> 
    <td> 
      <div align="center"> 
        <input type=button onClick=window.close() value=关闭窗口 name="button">
      </div>
    </td>
  </tr>
  <tr> 
    <td> 
      <!--#include file="include/copyright.asp"-->
    </td>
  </tr>
</table>
</body>
</html>



主要不明白第一行的if 判断什么了?
isempty这个函数,不是很明白,书本上写的是:返回boolean值,指明变量是否初始化!不太能理解~!

第二个问题是:
rs.update的作用,难道它不是对应rs.addnew吗?可以单独使用吗???



缺缺

职务:管理员
等级:8
金币:41.0
发贴:9620
注册:2004/1/14 19:14:47
#22004/2/13 22:32:29
就是判断是否为空,返回True/False

新增记录才需要rs.addnew,否则是更新,一般需要sql语句提供where来过滤