数据查询的出错显示控制应该如何?我还没输值,提示已出来
我加入了如果指针到头或到未则提示出错,请重新输入,但是第一次运行是提示已经出来,以后运行又正常了,控制语句应该怎样写?下面是原代码!
<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<!--#include file="Connections/lianjie.asp" -->
<%
Dim Recordset1__MMColParam
Recordset1__MMColParam = "1"
If (Request.Form("xuehao") <> "") Then
Recordset1__MMColParam = Request.Form("xuehao")
End If
%>
<%
Dim Recordset1__username
Recordset1__username = "王"
If (request.form("username") <> "") Then
Recordset1__username = request.form("username")
End If
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<style type="text/css">
<!--
.STYLE1 {font-size: 16px;
font-weight: bold;
}
.STYLE2 {font-size: 16px}
.STYLE4 {font-size: 16px; color: #FFFFFF; }
-->
</style>
</head>
<body>
<hr />
<table width="882" height="328" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="182"> </td>
<td width="471"> </td>
<td width="207"> </td>
</tr>
<tr>
<td> </td>
<td><form name="form1" method="post" action="">
<table width="752" height="304" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="158"> </td>
<td width="391" rowspan="3" bgcolor="#6A6A9B"><table width="318" height="234" border="1" align="center" cellpadding="0" cellspacing="1" bordercolor="#FFFFFF">
<tr>
<td width="310" height="228"><div align="center" class="STYLE2">
<p><img src="dot0001.gif" width="11" height="11" /><span class="STYLE4">请输入学号与姓名</span> <img src="dot0001.gif" width="11" height="11" /></p>
<p><img src="line01.jpg" width="103" height="6" /> <img src="line01.jpg" width="103" height="6" /></p>
</div>
<p align="center"><span class="STYLE4">请输入学号</span><span class="STYLE1"></span><span class="STYLE1">
<input name="xuehao" type="text" id="fenshu" size="20" />
</span></span></p>
<div align="center">
<p><br />
<span class="STYLE4">请输入姓名</span>
<input name="username" type="text" size="20" />
<br />
<br />
<img src="line01.jpg" width="103" height="6" /><img src="line01.jpg" width="103" height="6" /><br />
<br />
<input type="submit" name="Submit" value="提交"in="untitled" />
<input type="reset" name="Submit2" value="修改" />
</p>
</div>
</label>
<label> </label></td>
</tr>
</table></td>
<td width="181"> </td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td height="209"> </td>
<td> </td>
</tr>
</table>
<%
Dim Recordset1
Dim Recordset1_numRows
Set Recordset1 = Server.CreateObject("ADODB.Recordset")
Recordset1.ActiveConnection = MM_lianjie_STRING
Recordset1.Source = "SELECT * FROM dbo.fenshu WHERE 学号 = " + Replace(Recordset1__MMColParam, "'", "''") + " AND 姓名='" + Replace(Recordset1__username, "'", "''") + "'"
Recordset1.CursorType = 0
Recordset1.CursorLocation = 2
Recordset1.LockType = 1
Recordset1.Open()
Recordset1_numRows = 1
%>
<%
if Recordset1.bof or Recordset1.eof then
response.Write "格式不对,应该为7位数字请重新输入"
else %>
</form></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><table width="766" height="80" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#999999">
<tr>
<td width="10%" height="40" bgcolor="#6A6A9B">学号</td>
<td width="10%" bgcolor="#6A6A9B">姓名</td>
<td width="10%" bgcolor="#6A6A9B">大学物理</td>
<td width="10%" bgcolor="#6A6A9B">电路分析</td>
<td width="10%" bgcolor="#6A6A9B">高数</td>
<td width="10%" bgcolor="#6A6A9B">教育学 </td>
<td width="10%" bgcolor="#6A6A9B">新闻采编</td>
<td width="10%" bgcolor="#6A6A9B">英语</td>
<td width="10%" bgcolor="#6A6A9B">语文</td>
<td width="10%" bgcolor="#6A6A9B">地理</td>
</tr>
<tr>
<td width="10%" height="32"><div align="center"><%=Recordset1("学号")%></div></td>
<td width="10%" height="32"><div align="center"><%=Recordset1("姓名")%></div></td>
<td width="10%"><div align="center"><%=Recordset1("大学物理")%></div></td>
<td width="10%"><div align="center"><%=Recordset1("大学物理")%></div></td>
<td width="10%"><div align="center"><%=Recordset1("高数")%></div></td>
<td width="10%"><div align="center"><%=Recordset1("教育学")%></div></td>
<td width="10%"><div align="center"><%=Recordset1("新闻采编")%></div></td>
<td width="10%"><div align="center"><%=Recordset1("英语")%></div></td>
<td width="10%"><div align="center"><%=Recordset1("语文")%></div></td>
<td width="10%"><div align="center"><%=Recordset1("地理")%></div></td>
</tr>
</table></td>
<td> </td>
</tr>
</table>
<p> </p>
</body>
</html>
<%
end if
Recordset1.Close()
Set Recordset1 = Nothing
%>