我想要的效果是如果2个字段符合要求就显示数据库记录,否则提示错误信息,代码在下面,求高手帮我看看!
<%
dim name,zsbh
name=request("nam")
zsbh=request("bh")
set conn=server.Createobject("ADODB.Connection")
conn.open "Provider=Microsoft.Jet.Oledb.4.0;data source="&server.MapPath("xiaogan.mdb")
if name<>"" then
end if
str1="select * from zc where NAME='"&name&"' and ZSBH='"&zsbh&"'"
set rs=conn.Execute(str1)
%>
<p><strong><font color="#FF0000" size="2">查询结果:</font></strong></p>
</TD></TR></TBODY></TABLE>
<%if rs("NAME")="&name&" And rs("ZSBH")="&zsbh&" then
response.write "
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="24"> <font color="#333333"><strong>姓 名:</strong></font> <%=rs("NAME")%></td>
</tr>
<tr>
<td height="24"> <font color="#333333"><strong>性 别:</strong></font> <%=rs("XBIE")%></td>
</tr>
<tr>
<td height="24"> <strong><font color="#333333">出生年月:</font></strong> <%=rs("CSNY")%></td>
</tr>
<tr>
<td height="24"> <strong><font color="#333333">身份证号:</font></strong> <%=rs("SFEH")%></td>
</tr>
<tr>
<td height="24"> <strong><font color="#333333">专业资格:</font></strong> <%=rs("ZYZG")%></td>
</tr>
<tr>
<td height="24"> <strong><font color="#333333">级 别:</font></strong> <%=rs("JIBIE")%></td>
</tr>
<tr>
<td height="24"> <strong><font color="#333333">证书编号:</font></strong> <%=rs("ZSBH")%></td>
</tr>
<tr>
<td height="24"> <strong><font color="#333333">发证日期:</font></strong> <%=rs("FZRQ")%></td>
</tr>
<tr>
<td height="24"> </td>
</tr>
<tr>
<td height="24"> </td>
</tr>
</table>"
Next %>
<% <p align=center> 对不起,没有查讯到您需要的信息!</p><br>" %>
<% end if %>
參考答案:改过了,赶快试试吧
<%
dim name,zsbh
name=request("nam")
zsbh=request("bh")
set conn=server.Createobject("ADODB.Connection")
conn.open "Provider=Microsoft.Jet.Oledb.4.0;data source="&server.MapPath("xiaogan.mdb")
if name<>"" then
end if
str1="select * from zc where NAME='"&name&"' and ZSBH='"&zsbh&"'"
set rs=conn.Execute(str1)
%>
<p><strong><font color="#FF0000" size="2">查询结果:</font></strong></p>
</TD></TR></TBODY></TABLE>
<%
if not rs.eof then %>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="24"> <font color="#333333"><strong>姓 名:</strong></font> <%=rs("NAME")%></td>
</tr>
<tr>
<td height="24"> <font color="#333333"><strong>性 别:</strong></font> <%=rs("XBIE")%></td>
</tr>
<tr>
<td height="24"> <strong><font color="#333333">出生年月:</font></strong> <%=rs("CSNY")%></td>
</tr>
<tr>
<td height="24"> <strong><font color="#333333">身份证号:</font></strong> <%=rs("SFEH")%></td>
</tr>
<tr>
<td height="24"> <strong><font color="#333333">专业资格:</font></strong> <%=rs("ZYZG")%></td>
</tr>
<tr>
<td height="24"> <strong><font color="#333333">级 别:</font></strong> <%=rs("JIBIE")%></td>
</tr>
<tr>
<td height="24"> <strong><font color="#333333">证书编号:</font></strong> <%=rs("ZSBH")%></td>
</tr>
<tr>
<td height="24"> <strong><font color="#333333">发证日期:</font></strong> <%=rs("FZRQ")%></td>
</tr>
<tr>
<td height="24"> </td>
</tr>
<tr>
<td height="24"> </td>
</tr>
</table>
<% else %>
<% <p align=center> 对不起,没有查讯到您需要的信息!</p><br>" %>
<% end if %>