帮看看这个asp文件

来源:百度知道 编辑:UC知道 时间:2024/06/28 03:01:18
这个文件叫Channel.asp,内容通过Channel.asp?ChannelID=1这样的形式访问的。我的问题是怎么修改下,让Channel.asp可以直接访问id为1内容。而不用Channel.asp?ChannelID=1这样来访问了。

我的页面代码是

<!-- #include file="head.asp" -->

<%
Dim ChannelID,Cha_Name,Cha_Content
ChannelID=Trim(Request("ChannelID"))
If IsNumeric(ChannelID) = False Then
GoError "频道ID参数错误,请不要试图破坏此系统。"
End If

If ChannelID="" Then
FoundErr=True
ErrMsg=ErrMsg & "<br><li>无此频道信息或已被删除!</li>"
End If

sSql="Select ClassName,Content,ChannelType From OtherChannel Where ClassID="&ChannelID
oRs.Open sSql,oConn,1,1
If Not oRs.Eof Then
If oRs("ChannelType")=0 Then
Cha_Name=oRs("ClassName")
Cha_Content=oRs("Content")
Else
FoundErr=True
ErrMsg=ErrMsg & "<br><li>无此频道信息或已被删除!</li>"
End If
Else
Fo

<%
Dim ChannelID,Cha_Name,Cha_Content
ChannelID=1
sSql="Select ClassName,Content,ChannelType From OtherChannel Where ClassID=1"
oRs.Open sSql,oConn,1,1
If Not oRs.Eof Then
If oRs("ChannelType")=0 Then
Cha_Name=oRs("ClassName")
Cha_Content=oRs("Content")
Else
FoundErr=True
ErrMsg=ErrMsg & "<br><li>无此频道信息或已被删除!</li>"
End If
Else
FoundErr=True
ErrMsg=ErrMsg & "<br><li>无此频道信息或已被删除!</li>"
End If
oRs.Close
if FoundErr=True then
WriteErrMsg()
Response.End
End If
WebTitle=Cha_Name
%>

可以利用IsNull来判断一下ID的值是否存在,存在的话就读取该值,将使用您贴的代码来,当然了用判断是否为""也可以,如果不存在就将SQL语句改成Select ClassName,Content,ChannelType From OtherChannel Where id=1就可以了,如果你的那个ID值没有任何变化,就只有一个值的话,那就不必这样大动干戈了,直接将其改成Select ClassName,Content,ChannelType From OtherChannel Where id=1就成了。
动态网页的最主要含