积极分子思想汇报格式:那位高手指教一下 ASP编程方面

来源:百度文库 编辑:查人人中国名人网 时间:2024/05/07 16:50:52
下段代码是修改产品内容的代码,可是在测试中打不开指定的acritcleID的内容,老是出现"找不到该产品",请高手指教

<%
dim Action,FoundErr,ErrMsg
dim ArticleID,sql,rs
Action=trim(request("Action"))
ArticleID=trim(request("ArticleID"))
if Action="Modify" then
if ArticleId=" " then
response.write "请指定要修改的文章ID"
else
ArticleID=Clng(ArticleID)
sql="select * from Products where ArticleID=" & ArticleID & ""
Set rs= Server.CreateObject("ADODB.Recordset")
rs.open sql,conn,1,1
if rs.bof and rs.eof then
response.write "找不到该产品"
else
response.write "<p>" & rs("Content") & "</p>"
end if
rs.close
set rs=nothing
end if
end if
%>
下面是含有上段ASP代码的ASP文件:ProductContent.asp;刚才试过高手们的指点,问题好像出现在参数传递ArticleID上,ArticleID一直为空 .请高手赐教,教我怎么样才能将ArticleID参数传进来.

<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
<%
option explicit
response.buffer=true
'强制浏览器重新访问服务器下载页面,而不是从缓存读取页面
Response.Buffer = True
Response.Expires = -1
Response.ExpiresAbsolute = Now() - 1
Response.Expires = 0
Response.CacheControl = "no-cache"
%>
<!--#include file="inc/conn.asp"-->
<!--#include file="admin/admin.asp"-->
<!--#include file="inc/function.asp"-->
<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=gb2312">
<style type="text/css">body {font-size: 9pt}</style>
</head>
<BODY bgcolor="#FFFFFF" MONOSPACE>
<% 上段代码 %>
</body>
</html>
<%
call CloseConn()
%>

首先看看你的参数传递过来没有或传递的对不对
ArticleID=trim(request("AritcleID"))
response.write ArticleID
response.end

将显示出来ArticleID手工打开数据库看有没有这样的记录,没有,说明参数传递有问题

第二,检查SQL语句是否正确
sql="select * from Products where ArticleID=" & ArticleID & ""
response.write sql
response.end

Set rs= Server.CreateObject("ADODB.Recordset")

把if then else顺一下,我看有点乱.

sql="select * from Products where ArticleID=" & ArticleID & ""
如果ArticleID是字符串类型则
sql="select * from Products where ArticleID='" & ArticleID & "'"

如果ArticleID是整数类型则
sql="select * from Products where ArticleID=" & ArticleID