ASP中的参数问题

来源:百度知道 编辑:UC知道 时间:2024/05/01 08:59:15
<!--#include file="include/conn.asp"-->
<%
dim worktype1
wroktype1=request.QueryString("worktype1")
text_kind=request.form("text_kind")
text_topic=request.form("text_topic")
text_worker=request.form("text_worker")
text_message=request.form("text_message")
if worktype1="addnews" then
sql="insert into text1 (text_kind,text_topic,text_worker,text_message) values ('"&text_kind&"','"&text_topic&"','"&text_worker&"','"&text_message&"')"

rs.Open sql, conn, adOpenDynamic, 3
%>
<script>
alert("操作成功");
location.href="modynews.asp?worktype=add";
</script>
<%

else
Response.Write "<html><body><center><font size=5>有错误发生<p>"
end if
%>

这段

加了iF语句,就显示“有错误发生”这说明if worktype1="addnews" then
中worktype1="addnews"肯定为假,调试一下程序,主要检查worktype1的值,调试的方法可以在if worktype1="addnews" then 前面加入一句:
Response.Write(worktype1)看看输出是什么?

因为你没给出worktype1提交代码,只能根据location.href="modynews.asp?worktype=add";这一句
推断,应该worktype而不是worktype1所以
wroktype1=request.QueryString("worktype1")
应该改为:
wroktype1=request.QueryString("worktype")

wroktype1=request.QueryString("worktype1")
是读取url连接里面的提交的 worktype1的数据
你检查下看worktype1是url的传值还是form里的啦

好像是有错误:
dim worktype1
wroktype1=request.QueryString("worktype1")
if worktype1="addnews" then

form的action部分对应的asp语句后面带上参数worktype1=addnews