一個(gè)功能完善的專欄管理的程序->這是asp.net的第二個(gè)應(yīng)用(二) /* 豆腐制作,都是精品 http://www.asp888.net 豆腐技術(shù)站 如轉(zhuǎn)載,請(qǐng)保留完整版權(quán)信息 */ 我們?cè)谏掀恼轮校昧艘粋€(gè)函數(shù)包文件func.aspx,在這篇文章中,我們?cè)敿?xì)講解一下,這個(gè)func.aspx 文件 <%@ Assembly Name="System.Net" %> <%@ Import Namespace="System.Net" %> <%@ Import Namespace="System.IO" %> <%@ Import Namespace="System.Data" %> <%@ Import Namespace="System.Data.SQL" %> '這些import 我就不說(shuō)了,在前面的的文章 sp+中常用的NameSpace的講解都已經(jīng)有所涉及 <script language="VB" runat=server> function replaceSql(str1 as string) as string '在asp.net 中使用SQL 語(yǔ)句也會(huì)出現(xiàn)"'"號(hào)的問(wèn)題,因此使用replace函數(shù)將"'" 轉(zhuǎn)換成 "''" replaceSql=replace(str1,"'","''") end function function GetConn() as SQLConnection '我們?cè)谶@里 將連接數(shù)據(jù)庫(kù)的代碼進(jìn)行統(tǒng)一化管理 Dim conn As SQLConnection Dim Cfg as HashTable Cfg = Context.GetConfig("appsettings") Conn = New SQLConnection(cfg("Conn")) GetConn=Conn end function
sub WritePage(start as integer,file as string,intLen as integer,intPageCount as integer,intRecCount as integer) '這個(gè)是一個(gè) 可移植 的 分頁(yè)的程序 '進(jìn)行分頁(yè)處理 dim strWrite as string strWrite="<table border=1 width=100%><tr><td>" response.write(strWrite)
if start=0 then strWrite="首頁(yè)" else strWrite="<a href='" & file & "?start=0'>首頁(yè)</a>" end if response.write(strWrite)
if start>=1 then strWrite="<a href='" & file & "?start=" & cStr(start-intLen) & "'>上頁(yè)</a>" else strWrite="上頁(yè)" end if response.write(strWrite)
if start+intLen<intRecCount then '還沒(méi)有到最后一頁(yè)數(shù)據(jù) strWrite="<a href='" & file & "?start=" & cStr(start+intLen) & "'>下頁(yè)</a>" else strWrite="下頁(yè)" end if response.write(strWrite)
if start+intLen<intRecCount then '還沒(méi)有到最后一頁(yè)數(shù)據(jù) strWrite="<a href='" & file & "?start=" & cStr((intPageCount-1)*intLen) & "'>末頁(yè)</a>" else strWrite="末頁(yè)" end if response.write(strWrite & "</td><td>")