;
帖子
3919 
精华
积分
11710 
鱼币
0 ¥ 
来自
大连 
在线时间
1858 小时 
注册时间
2007-6-11 
最后登录
2009-10-20 

贴图大师勋章新人进步勋章宣传大使勋章论坛元老勋章

3
发表于 2009-1-5 19:48 | 只看该作者
浼樼鐨勭櫨涓囩骇鏁版嵁鍒嗛〉瀛樺偍杩囩▼浠g爜(ver2.0) - 缂栫▼搴 - Powered by SupeSite

浣犵殑浣嶇疆锛缂栫▼搴 >> 璧勮 >> 缃戠珯缂栫▼ >> ASP >> 璇︾粏鍐呭 鍦ㄧ嚎鎶曠ǹ

浼樼鐨勭櫨涓囩骇鏁版嵁鍒嗛〉瀛樺偍杩囩▼浠g爜(ver2.0)

鍙戝竷: 2008-7-28 09:48 |  浣滆: 缃戠粶杞浇 |   鏉ユ簮: 缃戠粶杞浇 |  鏌ョ湅: 96娆





<%
'骞冲彴锛歐in2000+IIS5.0+Sql2000
'闄勮█锛氬崌绾т笂涓娆$増鏈紝涓婁竴娆$増涓篠QL鐗堟湰锛屾病鏈夊埄鐢ㄤ笂瀛樺偍杩囩▼
'涓婁竴鐗堟湰 :[鍘熷垱]浼樼鐨勭櫨涓囩骇鏁版嵁鍒嗛〉浠g爜鈥斺(蹇欎箮浜嗗崐澶)(http://bbs.bc-cn.net/dispbbs.asp?BoardID=10&ID=175543)

'----------------------------------------浠ヤ笅浠g爜涓虹綉椤典唬鐮

Response.Buffer = True
Dim SqlLocalName,SqlUsername,SqlPassword,SqlDatabaseName
Dim ConnStr,Conn

'''''''''''''''''''''''''''''''''SQL鏁版嵁搴 ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
SqlLocalName   ="(local)"        '杩炴帴IP  [ 鏈湴鐢 (local) 澶栧湴鐢↖P ]
SqlUsername    ="sa"             '鏁版嵁搴撶敤鎴峰悕
SqlPassword    ="XXXXXX"         '鐢ㄦ埛瀵嗙爜
SqlDatabaseName="NewsTable"       '鏁版嵁搴撳悕
ConnStr = "Provider=Sqloledb;User ID=" & SqlUsername & "; Password=" & SqlPassword & "; Initial Catalog = " & SqlDatabaseName & "; Data Source=" & SqlLocalName & ";"
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
On Error Resume Next
Set Conn=Server.CreateObject("ADODB.Connection")
Conn.open ConnStr

If Err Then
   err.Clear
   Set Conn = Nothing
   Response.Write "<div style='font-size:14px;color=#ff0000' align='center'>鏁版嵁搴撹繛鎺ュ嚭閿欙紝璇锋鏌ユ暟鎹簱杩炴帴瀛椾覆</div>"
   Response.End
End If

'鏈被杩涜瀹炰緥鍖栦唬鐮侊紝涓嶅皢鎵鏈夊彲鑳芥ф潯浠跺垎椤佃冭檻杩涘幓銆傛湰绫讳粎浣滃弬鑰
'--------------------------------------------------------------------------------------------

'PageNo-褰撳墠椤;PageSizeX-鍒嗛〉澶у皬;PageCountX-鎬婚〉鏁;FieldCount-鎬昏褰曟暟;StrWhere-鏌ヨ鏉′欢
Dim PageNo,PageSizeX,PageCountX,FieldCount,StrWhere

'杩涜璧嬪
PageNo=trim(Request.Querystring("PageNo"))

PageSizeX=30                            '瀹氫箟鍒嗛〉澶у皬
if isnumeric(PageNo) or PageNo="" then  '濡傛灉娌℃湁Page鍊硷紝杩涜鍒濆鍖栧
   PageNo=abs(PageNo)
   if PageNo=0 then PageNo=1
else
   PageNo=1
end if

StrWhere="(ClassCode=0101 and Hits>20)"  '娉ㄦ剰锛屾澶勬敞鎰忓瓧绗︾殑闀垮害

set recom = server.createobject("adodb.command")
recom.activeconnection = Conn
recom.commandtype = 4

recom.commandtext = "News_Class"
recom.Parameters.Append  recom.CreateParameter("@StrWhere",202,1,100,StrWhere)
recom.Parameters.Append  recom.CreateParameter("@PageSize",3,1,,PageSizeX)
recom.Parameters.Append  recom.CreateParameter("@PageIndex",3,1,,PageNo)

set rs = recom.execute ()

if rs.eof then
   set rs=nothing : set recom=nothing  : Conn.Close : set Conn=nothing
   response.write "<script LANGUAGE='javascript'>alert('褰撳墠娌℃湁鎵惧埌浠讳綍璁板綍锛岃杩斿洖閲嶆柊鎿嶄綔锛');history.go(-1);</script>"
   response.end
end if

'鏄剧ず鏁版嵁
do while not rs.eof
   response.write""&rs("Title")&"&nbsp;&nbsp;&nbsp;娣诲姞鏃堕棿锛"&rs("AddTime")&"<br/>"
rs.movenext
loop

'鍙栧緱璁板綍鎬绘暟锛岃绠楅〉鏁
set rs = rs.NextRecordset
if rs("countx") > 0 then
   FieldCount=rs("countx")
else
   FieldCount=0
end if

if (FieldCount mod PageSizeX)>0 then
   PageCountX=((FieldCount - (FieldCount mod PageSizeX))/ PageSizeX)+1
else
   PageCountX= (FieldCount / PageSizeX)
end if

'杩涜鍏抽棴鍜岄噴鏀剧浉鍏宠祫婧
set rs=nothing : set recom=nothing  : Conn.Close : set Conn=nothing

'鏄剧ず鍒嗛〉
if PageNo<=1 then
   Response.Write "<font color='#FF0000'>[棣栭〉] [涓婁竴椤礭</font>"
else
   Response.Write"[<a href='?PageNo=1' target='_self' title='棣栭〉'><font color='#FF0000'>棣栭〉</font></a>] "
   Response.Write"[<a href='?PageNo="&(PageNo-1)&"' target='_self' title='涓婁竴椤'><font color='#FF0000'>涓婁竴椤</font></a>] "
end if

if PageNo>=PageCountX then
    Response.Write "<font color='#FF0000'>[涓嬩竴椤礭 [灏鹃〉]</font>"
else
    Response.Write"[<a href='?PageNo="&(PageNo+1)&"'  target='_self' title='涓嬩竴椤'><font color='#FF0000'>涓嬩竴椤</font></a>] "
    Response.Write"[<a href='?PageNo="&PageCountX&"' target='_self' title='灏鹃〉'><font color='#FF0000'>灏鹃〉</font></a>]"
end if

Response.Write"[椤垫 绗<font color=red>"&PageNo&"</font>椤/鍏<font color=red>" & PageCountX &"</font>椤礭"
Response.Write" [鍏<font color=red>"&FieldCount&"</font>鏉 <font color=red>"& PageSizeX & "</font>鏉/椤礭"

Response.Write"杞埌" & "<input id=zhuanpage name=zhuanpage size=2 value="&PageNo&">" & "椤<input type=submit value=""Go"" onclick=""gotoPage()"">"
Response.Write"</td></tr></table>"
Response.Write"<script>function gotoPage(){var pg=document.getElementById('zhuanpage').value;if(isNaN(pg)||pg>"&PageCountX& "||pg<0){window.alert('璇锋纭緭鍏ラ〉鐮,鍙兘涓烘鏁存暟!涓斾笉鑳藉ぇ浜"&PageCountX&"'); return false;}else{window.location.href='?PageNo='+document.getElementById('zhuanpage').value+'';return true;}}</script>"
%>


'--------------------------------------------------------浠ヤ笅浠g爜涓哄瓨鍌ㄨ繃绋嬩唬鐮
CREATE procedure  News_Class

--璧勮鏂伴椈鐧句竾绾у垎椤
(
@StrWhere     varchar(100),
@PageSize     int,        
@PageIndex    int      
)

AS

declare  @strSQL        varchar(2000)     -- 涓昏鍙
declare  @strCountSQL   varchar(2000)     -- 鎬昏褰曚富璇彞
declare  @strTmp        varchar(1000)     -- 涓存椂鍙橀噺

Set @strTmp =" Select top " + str(@PageSize) + " Title,AddTime from Tb_News "  --姝ゅ娉ㄦ剰锛岄渶鍑犱釜瀛楁璇诲嚑涓瓧娈

if @StrWhere<>''
   Begin

   Set @strSQL=@strTmp + " where ID < (select min(ID) from (select top " + str((@PageIndex-1)*@PageSize)+" ID from Tb_News Where "+@StrWhere+"  order by ID desc)  as tblTmp ) and "+@StrWhere+" order by ID desc"

   set @strCountSQL="select count(ID) as countx from Tb_News Where "+@StrWhere+" "

   End

else
   Begin

   Set @strSQL=@strTmp + " where ID < (select min(ID) from (select top " + str((@PageIndex-1)*@PageSize)+" ID from Tb_News order by ID desc)  as tblTmp ) order by ID desc"

   set @strCountSQL="select count(ID) as countx from Tb_News "

   End


if @PageIndex = 1
   if @StrWhere<>''
      Begin

      Set @strSQL=@strTmp +" Where "+@StrWhere+" order by ID desc"
      
      End
   else
      Begin

      Set @strSQL=@strTmp +" order by ID desc"
 
      End

exec (@strSQL)

exec (@strCountSQL)
GO

 
TAG: 浠g爜 鏁版嵁
鎵撳嵃 | 鏀惰棌姝ら〉 |  鎺ㄨ崘缁欏ソ鍙 | 涓炬姤
涓婁竴绡 涓嬩竴绡
 

璇勫垎锛0

鍙戣〃璇勮
鏌ョ湅鍏ㄩ儴鍥炲銆愬凡鏈0浣嶇綉鍙嬪彂琛ㄤ簡鐪嬫硶銆