| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 441 人关注过本帖
标题:[求助] asp问题
只看楼主 加入收藏
虫子世界
Rank: 1
等 级:新手上路
帖 子:32
专家分:0
注 册:2009-10-15
结帖率:57.14%
收藏
已结贴  问题点数:20 回复次数:4 
[求助] asp问题
以下是index.asp
<%set con = Server.CreateObject("adodb.connection")
connstr="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("*.mdb")
con.open connstr
%>
<%
function convert(str)
    str=replace(str,"'","’")
    str=replace(str,"""","&quot;")
    str=replace(str," ","&nbsp;")
    str=replace(str,"<","&lt;")
    str=replace(str," ","&gt;")
    str=replace(str,chr(13),"<br>")
    convert=str
End function
%><%
function newsConvert(str)
dim tempstr
dim theStr
dim canConvert
dim theChr
tempStr=str
theChr=""
theStr=""
canConvert=1
for i=1 to len(tempStr)
    theChr=mid(tempStr,i,1)
    if theChr="<" then
        canConvert=0
    end if
    if theChr=">" then
        canConvert=1
    end if
    if theChr=" " and canConvert=1 then
        theChr= "&nbsp;&nbsp;"
    end if
    theStr=theStr&theChr
next
    theStr=replace(theStr,chr(13),"<br>")
    newsConvert=theStr
End function
%>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<title><%=web_name%></title><!--#include file="../css.css"-->
</head>
<body>
<table width="986" height="10" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td></td>
  </tr>
</table>
<table width="986" height="300" border="1" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td width="200" valign="top" bgcolor="#EAE7E2"><!--#include file="left.asp" --></td>
    <td width="786" valign="top" bgcolor="#F3F0EB"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td height="35" align="center" bgcolor="#666666">我公司的相关产品系列</td>
      </tr>
      <tr>
        <td height="250" align="center" valign="top"><table width="95%" border="0" align="center" cellpadding="0" cellspacing="0" bordercolor="#FF9900">
        <%
        dim keyword
        dim sort_id
        keyword=request("keyword")
        sort_id=request("sort_id")
        if sort_id<>"" then sqlwhere=sqlwhere &" and sort_id="&sort_id&""
        if keyword<>"" then sqlwhere=sqlwher &" and shop_name like '%"&keyword&"%'"
        Set rs=Server.CreateObject("ADODB.RecordSet")
        if audit=1 then     'audit在库中是数值0和1,1为推荐、0为不推荐。
         strsql="select * from Product where audit=1 "&sqlwhere&" order by dateandtime desc"
         if tong= "'1'" then   'tong在库中是数值0和1,1为通过审核用户、0为没有通过审核有用户。
         strsql="select * from Product where shop_id<>0 "&sqlwhere&" order by dateandtime desc"
         else
         strsql="select * from Product where hueiproduct=0 "&sqlwhere&" order by dateandtime desc"    'hueiproduct在库中是数值0和1,1为审核用户可见产品、0为没有通过审核的用户不可见产品
         end if
         end if
        rs.Open strsql,con,1,1
    if rs.eof then
    if Sort_ID<>0 then
    response.write "</br></br><span class=title>暂无产品</span>"
    else
    response.write "</br></br><span class=title>暂无推荐产品</span>"
    end if
    else
        rs.movefirst
        if not isempty(request("page")) then   
           pagecount=cint(request("page"))   
        else   
           pagecount=1   
        end if
        rs.pagesize=6
        if pagecount>rs.pagecount or pagecount<=0 then              
           pagecount=1              
        end if              
        rs.AbsolutePage=pagecount
      %>
          <%
          j=1
          do while not (rs.eof or err)
          if (j mod 3)=1 then
              response.write "<tr>"
          end if
        %>
          <td align="center" valign="top"><table width="100%" height="125" border="0" align="center" cellpadding="4" cellspacing="0">
            <tr>
              <td width="150" align="center" valign="middle"><table width="120" border="0" cellpadding="1" cellspacing="0" bgcolor="#CCCCCC">
                <tr>
                  <td><table width="100%" border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF">
                    <tr>
                      <td align="center" valign="middle"><%If rs("Pic")<>"" then%>
                        <a href='List.asp?Shop_ID=<%=rs("Shop_ID")%>' target="_blank"><img border='0' width='120' height='120' src="Pic/<%=rs("pic")%>" align='center'></a>
                        <%Else%>
                        <a href='List.asp?Shop_ID=<%=rs("Shop_ID")%>' target="_blank"><img border='0' width='120' height='120' src='Pic/no.jpg' align='center'></a>
                        <%End If%></td>
                      </tr>
                    </table></td>
                  </tr>
                </table>
                <table width="100%" height="22"  border="0" align="center" cellpadding="0" cellspacing="0">
                  <tr>
                    <td align="center"><a class="a4" href="List.asp?Shop_id=<%=rs("shop_id")%>" target="_blank"><strong>[<%=left(rs("shop_name"),12)%>]</strong></a></td>
                    </tr>
                  </table></td>
              <td align="center" valign="middle"> </td>
              </tr>
            <tr>
              <td colspan="2" height="1" background="img/dot_02.gif"></td>
              </tr>
            </table></td>
            <%  
          if (j mod 3)=0 then
             response.write "</tr>"
          end if
          j=j+1
          rs.moveNext
          if j>6 then exit do
          loop
    end if
       %>
          </table>
<%
             if rs.pagecount>1 then
                response.Write "第"&pagecount&"页/共"&rs.pagecount&"页&nbsp;&nbsp;"
                if pagecount>=10 then
                   response.write"<a href=?Sort_ID="&sort_id&"&keyword="&keyword&"&page="&(((cstr(pagecount)\10)-1)*10)+1&"><<</a>&nbsp;&nbsp;"
                end if
                q=(cstr(pagecount)-1)\10
                if q<0 then
                   q=1
                end if
                p=(q*10)+1
                do while p<((q*10)+11)
                   If p=pagecount Then                        
                      Response.Write p&"&nbsp;&nbsp;"
                   Elseif p<=rs.pagecount then
                      Response.Write "<a href='?Sort_ID="&sort_id&"&keyword="&keyword&"&page="&p&"'>"& p &"</a>&nbsp;&nbsp;"
                   End If
                   p=p+1
                loop
                A=rs.pagecount
                if (A mod 10)=0 then
                    A=rs.pagecount-1
                end if
                if pagecount<(A\10)*10 then
                   response.write"<a href=?Sort_id="&Sort_id&"&keyword="&keyword&"&page="&((((cstr(pagecount)-1)\10)+1)*10)+1&">>></a>"
                end if
             End If%>
<% con.close
   set con=nothing
%>
</td>
      </tr>
    </table></td>
  </tr>
</table>
<table width="986" height="10" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td></td>
  </tr>
</table>
</body>
</html>

以下是left.asp
 <%if session("username")="" then%>
      <tr>
    <td height="35" colspan="2" align="center" valign="middle" bgcolor="#666666">会&nbsp;&nbsp;员&nbsp;&nbsp;登&nbsp;&nbsp;陆</td>
  </tr>
      <form action="user_login.asp" method="post" name="login" id="login">
        <tr>
          <td height="20" align="right" class="title">用户名:</td>
          <td height="20" align="left"><input name="username" type="text" id="username" size="12" maxlength="50" /></td>
        </tr>
        <tr>
          <td height="20" align="right" class="title">密码:</td>
          <td height="20" align="left"><input name="userpow" type="text" id="userpow" size="12" maxlength="50" /></td>
        </tr>
        <tr>
          <td height="20" colspan="2" align="center" valign="middle" class="title"><label>
            <input type="submit" name="button" id="button" value="提交">
          </label>
            &nbsp;&nbsp;&nbsp;&nbsp;<a href="user_apply.asp">注册</a></td>
        </tr>
      </form><%else%>
<tr>
    <td height="35" colspan="2" align="center" valign="middle" bgcolor="#666666">欢迎<%=session("username")%></td>
  </tr>
        <tr>
          <td height="20" colspan="2" align="center" valign="middle" class="title"><a href="user_exit.asp">退出登陆</a></td>
        </tr>
        <%end if%>

以下是user_login.asp

<%
dim conn
set conn = Server.CreateObject("adodb.connection")
conn.open "driver={microsoft access driver (*.mdb)};dbq="&server.MapPath("../data/data.mdb")
 %>
<%
if Request("username")<>"" then
    sql="select * from userhao where username='" & trim(request("username")) & "' and userpow='" & replace(trim(request("userpow")),"'","''") & "'"
    'response.write sql
    'response.End
    set rs = conn.Execute(sql)
    if not (rs.eof or err) then
        session("username")=rs("username")
        session("userpow")=rs("userpow")
        session("uuserfirm")=rs("uuserfirm")
        session("useradd")=rs("useradd")
        session("usertel")=rs("usertel")
        session("userfax")=rs("userfax")
        session("email")=rs("email")
        session("oicq")=rs("oicq")
        session("userreason")=rs("userreason")
        session("tong")=rs("tong")
        response.redirect "index.asp"
    else
%>
    <script language=Javascript>
    alert("错误!请重新输入");
    window.history.go(-1);   
    </script>
<%end if%>
<%end if%>

我想让它实现,当直接进入是,显示推荐产品,当点分类是显示全部产品,
当会员没有登陆时,显示全部产品(不包括会员产品)或者显示推荐产品。
当会员登陆且通过审的会员显示全部产品。


[ 本帖最后由 虫子世界 于 2009-10-28 11:07 编辑 ]
搜索更多相关主题的帖子: asp 
2009-10-28 10:32
aspic
Rank: 17Rank: 17Rank: 17Rank: 17Rank: 17
等 级:贵宾
威 望:51
帖 子:2258
专家分:8050
注 册:2008-2-18
收藏
得分:8 
根据某个参数判断 然后使用不同的sql语句
2009-10-28 11:18
chenguoxing517
Rank: 7Rank: 7Rank: 7
来 自:广东广州
等 级:黑侠
威 望:1
帖 子:154
专家分:619
注 册:2009-9-28
收藏
得分:5 
根据各种不同的条件判断,动态构造sql语句
2009-10-28 12:54
虫子世界
Rank: 1
等 级:新手上路
帖 子:32
专家分:0
注 册:2009-10-15
收藏
得分:0 
        if tong=rs("tong") then 这是第31行。怎么改呢?
         strsql="select * from Product where hueiproduct=1 "&sqlwhere&" order by dateandtime desc"
         else
         strsql="select * from Product where hueiproduct=0 "&sqlwhere&" order by dateandtime desc"
          end if
         if Sort_ID<>0 then
          strsql="select * from Product where Sort_ID<>0 "&sqlwhere&" order by dateandtime desc"
 
         else
         strsql="select * from Product where audit=1 "&sqlwhere&" order by dateandtime desc"
          end if
错误类型:
ADODB.Recordset (0x800A0CC1)
在对应所需名称或序数的集合中,未找到项目。
/Product/index.asp, 第 31 行
2009-10-28 13:14
aspic
Rank: 17Rank: 17Rank: 17Rank: 17Rank: 17
等 级:贵宾
威 望:51
帖 子:2258
专家分:8050
注 册:2008-2-18
收藏
得分:7 
没有读取出来或者没有这个字段
2009-10-28 14:46
快速回复:[求助] asp问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.016804 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved