您的位置:首页 > 编程语言 > VB

请你评一下我这个用VB写的分页的性能怎么样,是用DATASET(a,b,c,d)这个方法得到的数据

2009-03-23 23:06 543 查看
<script language="vb" runat="server">

sub page_load(objecta as object,e as eventargs)
Dim sql, rowa, clouma, curridex, uppagea, downpagea, downpageb As String
Dim autid As String = Request.QueryString("id") ' 要查找的ID号
Dim ident As String = Request.QueryString("ident") ' 判断要查找的是发表的何种评论
Dim pagesize As Integer = 5 '定义返回数据数值(行数)

curridex=request.QueryString("curridex")
if curridex="" then
curridex=0
else
curridex=request.QueryString("curridex")
end if

'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''以下是sql查询语句,
If ident = "dfweurjklsdfuiiwerk23d4kjsd" Then
rowa = "game table"
clouma = "yxxaaxxgz"
sql = "SELECT a.autoid,content,publishtime,a.tablename,[guest ip],title,[themes id] FROM [visitors book] as a inner join [game table] as b on a.[themes id]=b.[autoid] WHERE tablename='" + clouma + "' and [themes id]='" + autid + "'"
ElseIf ident = "psdfioeorjkxcusdflk3ksd4ks1q" Then
rowa = "log book table"
clouma = "xxyyxagz"
sql = "SELECT a.autoid,content,publishtime,tablename,[guest ip],title,[themes id] FROM [visitors book] as a inner join [log book table] as b on a.[themes id]=b.[autoid] WHERE tablename='" + clouma + "' and [themes id]='" + autid + "'"
ElseIf ident = "weriuklsjdfiwerkidufwer3wser" Then
rowa = "jx music world table"
clouma = "xammnyg"
sql = "SELECT a.autoid,content,publishtime,tablename,[guest ip],title,[themes id] FROM [visitors book] as a inner join [jx music world table] as b on a.[themes id]=b.[autoid] WHERE tablename= '" + clouma + "' and [themes id]='" + autid + "'"
ElseIf ident = "kiejsdfiwerjkuaisdfkwjer4g" Then
rowa = "jx world book table"
clouma = "xyxxaaaxygz"
sql = "SELECT a.autoid,content,publishtime,[guest ip],title,tablename,[themes id] FROM [visitors book] as a inner join [jx world book table] as b on a.[themes id]=b.[autoid] WHERE tablename='" + clouma + "' and [themes id]='" + autid + "'"
Else
Response.Redirect("fail.htm")
End If
'''''''''''''''''''''''''''''''''''''''''''''''’‘’‘’‘’‘’sql查询语句结束

'’‘’@@@@@‘’‘’‘’‘’‘’‘‘’‘’‘’‘’‘’‘’‘’‘’以下是数据链接代码
Dim conn As SqlConnection = New SqlConnection
Dim ad As New SqlDataAdapter()
Dim comd As SqlCommand
conn.ConnectionString = "persist security info=false;user id=sa;pwd=amwriuice;database=mysite application;server=(local)"
conn.Open()
'’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’‘’数据链接代码结束

Try
comd = New SqlCommand(sql, conn)
ad.SelectCommand = comd
Catch ex As Exception
Response.Redirect("fail.htm")
End Try
'''''''''''''''''''''''''''''''''统计数据表,绑定到REPEATER "teea" 中

Dim ds As Data.DataSet = New Data.DataSet '数据填充
Dim ds1 As Data.DataSet = New Data.DataSet
Dim cout As String
ad.fill(ds1, rowa)
cout = ds1.Tables(rowa).DefaultView.Count()

try
ad.Fill(ds,curridex, pagesize, rowa)
Catch ex2 As Exception
Response.Redirect("fail.htm")
End Try

'@@@@’‘’‘’‘’’‘’‘’‘’;'''‘’‘’‘‘’‘’ '赋值代码
firstpage.text=0'首页

uppage.text=curridex-pagesize '上一页
uppagea=curridex-pagesize
if uppagea<0 then
uppage.text=0
end if

downpage.text=curridex+pagesize '下一页
downpagea=curridex-pagesize
downpageb=curridex
if downpagea > ((convert.toint16(cout/pagesize))*pagesize) then
downpage.text=(convert.toint16(cout/pagesize))*pagesize
else if downpageb > ((convert.toint16(cout/pagesize))*pagesize-pagesize) then
downpage.text=(convert.toint16(cout/pagesize))*pagesize
end if

endpage.text=(convert.toint16(cout/pagesize))*pagesize '末页
''''''’‘’‘’‘’‘’‘@@’‘’‘’‘’‘’‘’‘赋值代码到此结束

conn.Close()
teea.DataSource = ds
teea.DataBind()
conn = Nothing
End Sub

</script>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐