注册 登录
编程论坛 ASP技术论坛

新闻浏览页面,求助!!!谢谢了!!!急!!!

gudaohaha 发布于 2008-05-18 10:43, 3004 次点击
请高手帮忙看下我的代码哪里出错了,我自己检查不出来啊,新闻浏览页面,查看新闻的,我可以运行,但是整个页面是空的,连里面包含的头文件都没有,而且没有任何出错信息,请帮忙哦,急需!!!谢谢了
主要代码如下:
<!--#include file="conn.asp"-->
<%
set rs=server.createobject("adodb.recordset")
set rscate=server.CreateObject("adodb.recordset")
rs.open "select * from news where newsid='"&request.QueryString("newsid")&"'",conn,1,3
if not rs.eof then
rqttitle=rs("newstitle")
rqtContent= rs("newsCONTENT")
rqtContent = replace(rqtContent,"[space]"," ")
'更新阅读数量
conn.Execute("UPDATE NEWS SET newsREADCOUNT = newsREADCOUNT + 1 WHERE newsID=" & Request.QueryString("newsid"))
'读取新闻类别
sql = "SELECT * FROM CATEGORY WHERE CID=" & rs("CID")
'执行查询
Set rsCate = conn.Execute(sql)
'如果记录集不为空,则设置新闻类别
If Not rsCate.EOF Then
stitle = rsCate("CNAME")
End If

'显示新闻标题、发表时间和内容
%>

<td height="184" colspan="4" valign="top"><!--#include file="head.asp"-->&nbsp;</td>
        </tr>
        <tr>
          <td width="27" height="60">&nbsp;</td>
          <td width="559" valign="top"><p class="style16"><strong>标题:<%=stitle%></strong>&nbsp;</p>
          <p class="style18"><%=rs("newsposttime")%>发表该新闻已被浏览过<%=rs("newsreadcount")%>次&nbsp;&nbsp;&nbsp;&nbsp;作者:<%=rs("newsposterid")%></font></span>&nbsp;</p></td>
          <td width="28">&nbsp;</td>
          <td width="216" rowspan="2" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
        </tr>
        <tr>
          <td height="1244" colspan="3" valign="top">
            <span class="style16"><%=rqtContent%>
       &nbsp;</span></td>
        </tr>
    </table></td>
     <div align="center"><br>         
          <input name="Submit" type="button" class="STYLE11" onClick="javascritp:window.close()" value="关闭窗口">
      </div>
        <div align="right"><a href="newDiscuss.asp?newsid=<%=Request("newsid")%>" class="style15">发表评论 </a></div></td></tr>
    <td>&nbsp;</td>
30 回复
#2
hxfly2008-05-18 10:46
response.write("select * from news where newsid='"&request.QueryString("newsid")&"'")
response.end
如果输出的SQL语句正确,那在数据库中执行下SQL语句,看看有结果没
#3
gudaohaha2008-05-18 10:54
再问
请问下,那句应该放哪里啊,我之前的就是运行一下整个页面就是空白页,什么东西都没有的???
#4
hxfly2008-05-18 10:56
<!--#include file="conn.asp"-->
<%
response.write("select * from news where newsid='"&request.QueryString("newsid")&"'")
response.end
%>
#5
hxfly2008-05-18 10:59
取到你那样的结果说明newsid你没传过来
request.QueryString("newsid")的值是空,数据库查不到结果,当然不显示了....
#6
gudaohaha2008-05-18 11:05
可是为什么会这样呢,我数据可没有出错啊???
#7
hxfly2008-05-18 11:07
可能不关数据的事情,是你没把newsid这个字符串传递过来
现在的这个页,不能直接运行,需要其他页面传递newsid给他他才能运行....
#8
gudaohaha2008-05-18 11:11
<%
            Set rs = Server.CreateObject("ADODB.RecordSet")
            sql="select * from News,Category where news.CateID=Category.CID and '热点新闻' order by NewsID desc"
            rs.open sql,conn,3,2
            on error resume next
            if not rs.eof then
            for i=1 to 5            
            Response.Write "<a class='style25' onClick='return newwin(this.href);' href='newsView.asp?id=" + cstr(rs("newsid")) + "'>" + rs("newsTitle") +"</p>"
            rs.movenext
            next
            rs.close
            end if
            %>        

这是我主页的读取新闻题目的代码,我就是从主页这里点击进去,然后跳到那个浏览的页面,麻烦帮我看看要怎么改吧,我实在是看不出来了哦
#9
yms1232008-05-18 16:12
on error resume next
楼主代码里的这种语句去掉,这种语句会屏蔽错误信息。
#10
gudaohaha2008-05-18 16:20
错误类型:
(0x80020009)
发生意外。
/new/index.asp, 第 203 行

可是如果去掉的话,我就出错了,在新闻的主页面那,Response.Write "<a class='style25' onClick='return newwin(this.href);' href='newsView.asp?id=" + cstr(rs("newsid")) + "'>" + rs("newsTitle") +"</p>"
            rs.movenext
#11
yms1232008-05-18 16:26
错误类型:
(0x80020009)
发生意外。
/new/index.asp, 第 203 行
全部的错误信息?
#12
gudaohaha2008-05-18 16:31
恩,是啊,就只有这么一点提示的
#13
yms1232008-05-18 16:37
sql="select * from News,Category where news.CateID=Category.CID and '热点新闻' order by NewsID desc"
热点新闻确认有超过5条?
#14
gudaohaha2008-05-18 16:40
额,热点新闻那里倒是没出错,是另一个类别的新闻那里出错了,不过那真的只暂时添加了一条新闻,和那个有关系的吗??我试试先
#15
gudaohaha2008-05-18 16:43
好厉害的说,现在主页是没有问题了,就是新闻浏览页面还是看不到什么东西,点进去了,就是空白,也没有提示出错,连有包含的头文件什么的都没有了
#16
yms1232008-05-18 16:59
<!--#include file="conn.asp"-->
这个文件里的代码是怎么写的?
#17
gudaohaha2008-05-18 17:00
<%    
    '数据库连接变量定义
    'Dim conn
    
    '数据库连接
    Set conn = Server.CreateObject("ADODB.Connection")
    '数据库连接字符串                        
      conn.ConnectionString = "Provider=SQLOLEDB;Data Source=(local);Initial Catalog=new;User ID=sa; PASSWORD=841218"
      '打开数据库连接
    conn.Open
    
    '由程序处理错误,而不是缺省的由解释器处理错误
    If Err Then
        '发生错误,进行错误处理
        '释放数据库连接对象,并提示用户连接数据库出错
        Err.Clear
        Set conn = Nothing
        Response.Write "数据库连接出错,请检查连接字串。"
        'esponse.End
    End If
%>
#18
yms1232008-05-18 17:18
If Err Then
        '发生错误,进行错误处理
        '释放数据库连接对象,并提示用户连接数据库出错
        Err.Clear
        Set conn = Nothing
        Response.Write "数据库连接出错,请检查连接字串。"
        'esponse.End
    End If
把错误处理注释掉看看。
#19
gudaohaha2008-05-18 17:19
还是一样的,什么都没有哦
#20
yms1232008-05-18 17:21
<!--#include file="head.asp"-->
里面是怎么写的?
#21
yms1232008-05-18 17:24
<%
response.write("select * from news where newsid='"&request.QueryString("newsid")&"'")
response.end
%>
楼主网页里加了这段代码?
#22
gudaohaha2008-05-18 17:28
恩,加了之后是整个页面只显示select * from news where newsid=''这句话,所以注销掉了,我的HEAD.ASP里面没有包含任何ASP代码的,因为所以的新闻类别那些都是直接用FLASH文本做的,不是从数据库里读的哦,用数据库读的我子页面不会做,所以……
#23
yms1232008-05-18 17:37
select * from news where newsid='"&request.QueryString("newsid")&"'"
证明提交过来的页面没有获得newsid的值
request.QueryString("newsid")这个没有获得任何数据
#24
gudaohaha2008-05-18 17:40
可是这样的话要怎么改呢,<%
            Set rs = Server.CreateObject("ADODB.RecordSet")
            sql="select * from News,Category where news.CateID=Category.CID and '热点新闻' order by NewsID desc"
            rs.open sql,conn,3,2
            'on error resume next
            if not rs.eof then
            for i=1 to 5            
            Response.Write "<a class='style25' onClick='return newwin(this.href);' href='newsView.asp?id=" + cstr(rs("newsid")) + "'>" + rs("newsTitle") +"</p>"
            rs.movenext
            next
            rs.close
            end if
            %>            


这是主页的读新闻题目的语句
#25
yms1232008-05-18 17:42
<!--#include file="conn.asp"-->
<%
set rs=server.createobject("adodb.recordset")
set rscate=server.CreateObject("adodb.recordset")
rs.open "select * from news where newsid='"&request.QueryString("newsid")&"'",conn,1,3
if not rs.eof then
rqttitle=rs("newstitle")
rqtContent= rs("newsCONTENT")
rqtContent = replace(rqtContent,"[space]"," ")
'更新阅读数量
conn.Execute("UPDATE NEWS SET newsREADCOUNT = newsREADCOUNT + 1 WHERE newsID=" & Request.QueryString("newsid"))
'读取新闻类别
sql = "SELECT * FROM CATEGORY WHERE CID=" & rs("CID")
'执行查询
Set rsCate = conn.Execute(sql)
'如果记录集不为空,则设置新闻类别
If Not rsCate.EOF Then
stitle = rsCate("CNAME")
End If

'显示新闻标题、发表时间和内容
%>

<td height="184" colspan="4" valign="top"><!--#include file="head.asp"--> </td>
        </tr>
        <tr>
          <td width="27" height="60"> </td>
          <td width="559" valign="top"><p class="style16"><strong>标题:<%=stitle%></strong> </p>
          <p class="style18"><%=rs("newsposttime")%>发表该新闻已被浏览过<%=rs("newsreadcount")%>次    作者:<%=rs("newsposterid")%></font></span> </p></td>
          <td width="28"> </td>
          <td width="216" rowspan="2" valign="top"><!--DWLayoutEmptyCell--> </td>
        </tr>
        <tr>
          <td height="1244" colspan="3" valign="top">
            <span class="style16"><%=rqtContent%>
        </span></td>
        </tr>
    </table></td>
     <div align="center"><br>         
          <input name="Submit" type="button" class="STYLE11" onClick="javascritp:window.close()" value="关闭窗口">
      </div>
        <div align="right"><a href="newDiscuss.asp?newsid=<%=Request("newsid")%>" class="style15">发表评论 </a></div></td></tr>
    <td> </td>
这些代码所在页面的文件名是什么?
#26
gudaohaha2008-05-18 17:45
是在newsview里面的啊
#27
yms1232008-05-18 17:47
Response.Write "<a class='style25' onClick='return newwin(this.href);' href='newsView.asp?id=" + cstr(rs("newsid")) + "'>" + rs("newsTitle") +"</p>"
这里的错误
    Response.Write "<a class='style25' onClick='return newwin(this.href);' href='newsView.asp?newsid=" + cstr(rs("newsid")) + "'>" + rs("newsTitle") +"</p>"
改成这样看看。
#28
gudaohaha2008-05-18 17:52
还是不行哦
他的URL其实是可以显示ID的,是这样的http://localhost/new/newsView.asp?newsid=4,不然你告诉我Q吧行不,给你远程???
#29
yms1232008-05-18 17:55
select * from news where newsid=''
如果显示这句话证明request.QueryString("newsid")没有得到数据
#30
gudaohaha2008-05-18 17:56
我知道,可是我看不出哪里有错误哦,所以还是不懂诶……嘿嘿
#31
gudaohaha2008-05-18 22:43
晕啊,怎么大家都是说到这就不理我了啊,555555555555555
1