![]() |
#2
wf2352013-01-25 17:21
ts2.asp 代码
![]() <!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.> 目前问题如图:<%@Language="VBScript" CodePage="65001"%> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <% dim conn dim connstr Connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("dbdate/zswap.mdb") Set conn = Server.CreateObject("ADODB.Connection") Conn.Open Connstr %> <% dim CheckCode CheckCode=replace(trim(Request("CheckCode")),"'","") if CheckCode="" or request("cpid")="" or request("cpname")="" or request("bigclass")="" or request("smallclass")="" or request("pic")="" or request("size")="" or request("note")="" then FoundErr=True ErrMsg=ErrMsg & "<br><li> * 项不能为空!</li>" end if if session("CheckCode")="" then FoundErr=True ErrMsg=ErrMsg & "<br><li>你登录时间过长,请重新返回登录页面进行登录。</li>" end if if CheckCode<>CStr(session("CheckCode")) then FoundErr=True ErrMsg=ErrMsg & "<br><li>您输入的确认码和系统产生的不一致,请重新输入。</li>" end if if FoundErr=True then call WriteErrMsg() end if sub WriteErrMsg() dim strErr strErr=strErr & "<html><head><title>错误信息</title><meta http-equiv='Content-Type' content='text/html; charset=utf-8' />" & vbcrlf strErr=strErr & "</head><body>" & vbcrlf strErr=strErr & "<table cellpadding=2 cellspacing=1 border=0 width=400 class='border' align=center>" & vbcrlf strErr=strErr & " <tr align='center'><td height='22' class='title'><strong>错误信息</strong></td></tr>" & vbcrlf strErr=strErr & " <tr><td height='100' class='tdbg' valign='top'><b>产生错误的可能原因:</b><br>" & errmsg &"</td></tr>" & vbcrlf strErr=strErr & " <tr align='center'><td><a href='ts1.asp'><< 返回</a></td></tr>" & vbcrlf strErr=strErr & "</table>" & vbcrlf strErr=strErr & "</body></html>" & vbcrlf response.write strErr end sub %> <% if FoundErr<>True then set rs=server.createobject("adodb.recordset") sql2="select * from pro " rs.open sql2,conn,1,1 if rs("cpid")=request("cpid") then sql="update pro set cpname='"&request("cpname")&"',bigclass='"&request("bigclass")&"',smallclass='"&request("smallclass")&"',pic='"&request("pic")&"',size='"&request("size")&"',note='"&request("note")&"' where id="&request("id")&" " else sql="insert into pro ([cpid],[cpname],[bigclass],[smallclass],[pic],[size],[note]) values ('"&request("cpid")&"','"&request("cpname")&"','"&request("bigclass")&"','"&request("smallclass")&"','"&request("pic")&"','"&request("size")&"','"&request("note")&"') " end if conn.execute(sql) response.Write("<a href='ts1.asp' onClick=""return confirm('添加成功,是否继续?')"">继续添加</a>") response.end() end if %> 只有本站会员才能查看附件,请 登录 |
只有本站会员才能查看附件,请 登录
页面代码:

<!DOCTYPE html PUBLIC "-//WAPFORUM//DTD XHTML Mobile 1.0//EN" "http://www.>
<%@Language="VBScript" CodePage="65001"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>产品添加</title>
</head>
<%
dim conn
dim connstr
Connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("dbdate/zswap.mdb")
Set conn = Server.CreateObject("ADODB.Connection")
Conn.Open Connstr
%>
<body>
<form id="search" name="search" method="post" action="ts1.asp" target="_parent">
<table width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="50"><div align="center">序号</div></td>
<td width="250"><div align="center">产品编码</div></td>
<td><div align="center">产品类名</div></td>
<td width="50"><div align="center">查询</div></td>
</tr>
<tr>
<td> </td>
<td>
<div align="center">
<input name="searchtxt" type="text" id="searchtxt" size="30" />
</div></td>
<td><div align="center">
<input type="submit" name="searchgo" id="searchgo" value="搜索" />
</div></td>
<td> </td>
</tr>
<%
set rs=server.createobject("adodb.recordset")
if request("searchtxt")<>"" then
sql="select * from pro where cpid = '"&request("searchtxt")&"' order by id desc"
else
sql="select top 5 * from pro order by id desc"
end if
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write " <script language=""javascript"">alert(""请核对产品编码!"")</script>"
end if
%>
<%
do while not rs.eof
%>
<form id="chaxun" name="chaxun" method="post" action="ts1.asp" target="_parent">
<tr>
<td><div align="center"><%=rs("id")%></div></td>
<td><div align="center"><%=rs("cpid")%></div></td>
<td><div align="center"><%=rs("cpname")%></div></td>
<td><div align="center">
<input type="submit" name="chaxun" id="chaxun" value="查询" />
</div></td>
</tr>
<%
set rs2=server.createobject("adodb.recordset")
sql2="select * from pro where id= "&rs("id")&" "
rs2.open sql2,conn,1,1
%>
</form>
<%
rs.movenext
loop
rs.close
%>
</table>
</form>
<form name="form1" method="post" action="ts2.asp" target="_parent">
<table width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="90"><div align="right">产品编号: </div></td>
<td colspan="2"><input name="cpid" type="text" id="cpid" value="<%=rs2("cpid")%>"></td>
<td width="50%"><font color="#FF0000"> * </font><font color="#999999">如:PACD1020 </font></td>
</tr>
<tr>
<td><div align="right">产品名称: </div></td>
<td colspan="2"><input name="cpname" type="text" id="cpname" value="<%=rs2("cpname")%>"></td>
<td><font color="#FF0000">* </font><font color="#999999">如:亚克力珠</font></td>
</tr>
<tr>
<td><div align="right">产品大类: </div></td>
<td colspan="2"><input name="bigclass" type="text" id="bigclass" value="<%=rs2("bigclass")%>"></td>
<td><font color="#FF0000">* </font><font color="#999999">两类:1,亚克力sb1s;2,LED灯sb2s</font></td>
</tr>
<tr>
<td><div align="right">产品小类: </div></td>
<td colspan="2"><input name="smallclass" type="text" id="smallclass" value="<%=rs2("smallclass")%>"></td>
<td><font color="#FF0000">*</font><font color="#999999"> 如:亚克力珠,s11s</font></td>
</tr>
<tr>
<td><div align="right">图片地址: </div></td>
<td colspan="2"><input name="pic" type="text" id="pic" value="<%=rs2("pic")%>"></td>
<td><font color="#FF0000">*</font><font color="#999999"> 如:img/pccd0120.jpg</font></td>
</tr>
<tr>
<td><div align="right">产品规格: </div></td>
<td colspan="2"><input name="size" type="text" id="size" value="<%=rs2("size")%>"></td>
<td><font color="#999999">如:20*25*10 单位:mm</font></td>
</tr>
<tr>
<td><div align="right">详细资料:</div></td>
<td height="50" colspan="3"><textarea name="note" cols="50" rows="5" id="note"><%=rs2("note")%></textarea>
<font color="#FF0000">*</font></td>
</tr>
<tr>
<td><div align="right">验证码:</div></td>
<td width="131">
<input name="CheckCode" size="6" maxlength="4" style="border-style:solid;border-width:1;padding-left:4;padding-right:4;padding-top:1;padding-bottom:1" onmouseover="this.style.background='#E1F4EE';" onmouseout="this.style.background='#FFFFFF'" onfocus="this.select(); " />
<img src="checkcode.asp" alt="" /><font color="#FF0000">*</font></td>
<td width="65"><input type="submit" name="up" id="up" value="提交" /></td>
<td> </td>
</tr>
</table>
</form>
</body>
</html>
目前的问题是,当没有查询关键词时,不能点击列出的查询按钮查询该ID产品,当查询无结果时,RS2(“ID”)无返回而报错<%@Language="VBScript" CodePage="65001"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>产品添加</title>
</head>
<%
dim conn
dim connstr
Connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("dbdate/zswap.mdb")
Set conn = Server.CreateObject("ADODB.Connection")
Conn.Open Connstr
%>
<body>
<form id="search" name="search" method="post" action="ts1.asp" target="_parent">
<table width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="50"><div align="center">序号</div></td>
<td width="250"><div align="center">产品编码</div></td>
<td><div align="center">产品类名</div></td>
<td width="50"><div align="center">查询</div></td>
</tr>
<tr>
<td> </td>
<td>
<div align="center">
<input name="searchtxt" type="text" id="searchtxt" size="30" />
</div></td>
<td><div align="center">
<input type="submit" name="searchgo" id="searchgo" value="搜索" />
</div></td>
<td> </td>
</tr>
<%
set rs=server.createobject("adodb.recordset")
if request("searchtxt")<>"" then
sql="select * from pro where cpid = '"&request("searchtxt")&"' order by id desc"
else
sql="select top 5 * from pro order by id desc"
end if
rs.open sql,conn,1,1
if rs.eof and rs.bof then
response.write " <script language=""javascript"">alert(""请核对产品编码!"")</script>"
end if
%>
<%
do while not rs.eof
%>
<form id="chaxun" name="chaxun" method="post" action="ts1.asp" target="_parent">
<tr>
<td><div align="center"><%=rs("id")%></div></td>
<td><div align="center"><%=rs("cpid")%></div></td>
<td><div align="center"><%=rs("cpname")%></div></td>
<td><div align="center">
<input type="submit" name="chaxun" id="chaxun" value="查询" />
</div></td>
</tr>
<%
set rs2=server.createobject("adodb.recordset")
sql2="select * from pro where id= "&rs("id")&" "
rs2.open sql2,conn,1,1
%>
</form>
<%
rs.movenext
loop
rs.close
%>
</table>
</form>
<form name="form1" method="post" action="ts2.asp" target="_parent">
<table width="600" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="90"><div align="right">产品编号: </div></td>
<td colspan="2"><input name="cpid" type="text" id="cpid" value="<%=rs2("cpid")%>"></td>
<td width="50%"><font color="#FF0000"> * </font><font color="#999999">如:PACD1020 </font></td>
</tr>
<tr>
<td><div align="right">产品名称: </div></td>
<td colspan="2"><input name="cpname" type="text" id="cpname" value="<%=rs2("cpname")%>"></td>
<td><font color="#FF0000">* </font><font color="#999999">如:亚克力珠</font></td>
</tr>
<tr>
<td><div align="right">产品大类: </div></td>
<td colspan="2"><input name="bigclass" type="text" id="bigclass" value="<%=rs2("bigclass")%>"></td>
<td><font color="#FF0000">* </font><font color="#999999">两类:1,亚克力sb1s;2,LED灯sb2s</font></td>
</tr>
<tr>
<td><div align="right">产品小类: </div></td>
<td colspan="2"><input name="smallclass" type="text" id="smallclass" value="<%=rs2("smallclass")%>"></td>
<td><font color="#FF0000">*</font><font color="#999999"> 如:亚克力珠,s11s</font></td>
</tr>
<tr>
<td><div align="right">图片地址: </div></td>
<td colspan="2"><input name="pic" type="text" id="pic" value="<%=rs2("pic")%>"></td>
<td><font color="#FF0000">*</font><font color="#999999"> 如:img/pccd0120.jpg</font></td>
</tr>
<tr>
<td><div align="right">产品规格: </div></td>
<td colspan="2"><input name="size" type="text" id="size" value="<%=rs2("size")%>"></td>
<td><font color="#999999">如:20*25*10 单位:mm</font></td>
</tr>
<tr>
<td><div align="right">详细资料:</div></td>
<td height="50" colspan="3"><textarea name="note" cols="50" rows="5" id="note"><%=rs2("note")%></textarea>
<font color="#FF0000">*</font></td>
</tr>
<tr>
<td><div align="right">验证码:</div></td>
<td width="131">
<input name="CheckCode" size="6" maxlength="4" style="border-style:solid;border-width:1;padding-left:4;padding-right:4;padding-top:1;padding-bottom:1" onmouseover="this.style.background='#E1F4EE';" onmouseout="this.style.background='#FFFFFF'" onfocus="this.select(); " />
<img src="checkcode.asp" alt="" /><font color="#FF0000">*</font></td>
<td width="65"><input type="submit" name="up" id="up" value="提交" /></td>
<td> </td>
</tr>
</table>
</form>
</body>
</html>
请教解决办法