标题:帮我解释下里面代码中打开数据库语句!
只看楼主
hwc98
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2011-10-20
结帖率:100%
已结贴  问题点数:10 回复次数:1 
帮我解释下里面代码中打开数据库语句!
麻烦好心人耐心帮我看下这段代码,有个数据库调用语句看不懂,搞的我自学不下去.

<TABLE width=767 height=50 border=0 align="center" cellPadding=0 cellSpacing=0 id=__01>
  <TBODY>
  <TR>
  <TD width="218" valign="top">
  <!--#include file="login.asp"-->
  <!--#include file="cd.asp"-->
  <!-- End ImageReady Slices --></TD>
  <TD width="549" valign="top" bgcolor="#FFFFFF"><span class="td02">
  <%
if request("TypeNo")<>"" then
opendb "","proType","TypeNo='"&request("TypeNo")&"'","","",typeno
title=typeno("TypeNameEn")
TextCom=typeno("contente")
opendb "","proType","id="&typeno("PID"),"","",PType
title = PType("TypeNameEn") & "&nbsp;&nbsp;>&nbsp;&nbsp;" & title
closedb typeno
closedb PType
end if
%>
  </span>
  <TABLE width=549 border=0 cellPadding=0 cellSpacing=0 background="images/line_lv.gif" id=__01>
  <TBODY>
  <TR>
  <TD><IMG height=15 alt="" src="images/4_02.gif" width=549></TD>
  </TR>
  <TR>
  <TD><IMG height=32 alt="" src="images/custom.gif" width=549></TD>
  </TR>
  <TR>
  <TD height="94" valign="top" background="images/line_lv2.gif" class="about_index" style="padding:8px;">
  <%
if request("TypeNo")<>"" then
lmid=221
opendb "","news","(lm='"&lmid&"' or lm2='"&lmid&"' or lm3='"&lmid&"')","","",rss
if not rss.eof then
content= rss("contente")
else
content= "<center><br><br>In data compilation</center>"
end if
closedb rss
response.Write TextCom
else
response.write"  We are able to provide customers a wide range of toy products, including remote control toys, electric toys, ..........."
end if

这个打开数据库自定义函数func.asp是下面:
'========打开数据库===================================================
'TD 数据库字段名,可以为空
'TB 数据库表名
'WHERE 查询条件
'BY 以哪个字段排序
'PX 排序方式,1 为正序 ,2为倒序
'SS 数据集名
'
'=====================================================================
function openDB(tu,tb,where,by,px,ss)
dim qq,where2,by2,px2
if tu="" then
tu="*"
end if
if where="" then
where2=""
else
where2=" where "&where
end if
if by="" then
by2=""
else
by2=split(by,",")
if px<>"" then
px2=split(px,",")
end if
for i=0 to ubound(px2)
if px2(i)=1 then
px2(i)=" asc"
else
px2(i)=" desc"
end if
next
redim preserve px2(ubound(by2))
for i=0 to ubound(by2)
if px2(i)="" then px2(i)=" desc"
by3=by3&","&by2(i)&px2(i)
next
by3=right(by3,len(by3)-1)

by4=" order by "&by3
end if

qq="select "&tu&" from "&tb&where2&by4
set ss=server.createobject("adodb.recordset")
ss.open qq,conn,3,3
end function
======================================================================

疑问:opendb "","news","(lm='"&lmid&"' or lm2='"&lmid&"' or lm3='"&lmid&"')","","",rss 这个调用
是不是打开数据库中news表啊?但是表里没有什么内容. 也没有“contente”这个字段啊。 lmid=221 ,(lm='"&lmid&"' or lm2='"&lmid&"' or lm3='"&lmid&"')怎么理解啊?  
搜索更多相关主题的帖子: 数据库 自学 request include border 
2011-10-22 15:44
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
得分:10 
qq="select "&tu&" from "&tb&where2&by4
最关键的是这句话,上面的一堆判断都在为了生成这句话。
2011-10-23 15:50



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-353152-1-1.html




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

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