请点评我写这个分页代码,本人是个菜鸟。不知道这代码好不好?

amwriuice398752815 2009-03-23 11:14:58
麻烦各位高手看下,点下了^-^


<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>
...全文
65 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复

62,267

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧