浏览ORACLE数据库并分页显示

gao 2000-07-25 10:39:00
浏览ORACLE数据库并分页显示
我可以浏览MS SQLSERVER数据库并分页显示,但无法对ORACLE实现该功能,
请提供原代码,多谢!
...全文
241 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
gao 2000-07-26
  • 打赏
  • 举报
回复
这个问题hblinux和Firing_Sky 讲的很好,
请大家到ASP已解决的问题->:浏览ORACLE数据库并分页显示 ->200分!!!!

华南虎哥 2000-07-26
  • 打赏
  • 举报
回复
你可以把util.asp文件内容作以下修正:
__________________________________________________
<%
Function OpenOrGet_Database( SessionName )

Dim conn

If Not IsObject(Session(SessionName)) Then
Set conn = Server.CreateObject("ADODB.Connection")
Conn.Open "Provider=msdaora;Data Source=AJGL;User Id=case;Password=why;"
Set Session(SessionName) = conn
End If
Set OpenOrGet_Database = Session(SessionName)
End Function

Function OpenOrGet_RsAndPageSize( conn, sql, SessionName, PageSize )
Dim rs

If Not IsObject(Session(SessionName)) Then
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql, conn, adOpenStatic
Set Session(SessionName) = rs
rs.PageSize = PageSize
End If
Set OpenOrGet_RsAndPageSize = Session(SessionName)
End Function

Function Open_RsAndPageSize( conn, sql, SessionName, PageSize )
Dim rs

Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql, conn, adOpenStatic
Set Session(SessionName) = rs
rs.PageSize = PageSize
Set Open_RsAndPageSize = Session(SessionName)
End Function
%>
------------------------------------------------------
至于下面一段HTML代码就删除不要,onepage.asp里除你编的ASP代码要之外,其他也删掉,试试,不行再EMAIL:hblinux@163.net
gao 2000-07-25
  • 打赏
  • 举报
回复
我的代码?没有成功,请大家指点错在那里
pagebrow.asp
<!--#include file="adovbs.inc" -->
<!--#include file="OnePage.asp" -->
<!--#include file="Util.asp" -->
<%
Set conn = OpenOrGet_Database( session("test_conn"))
If Request("Page") = "" Then
Set rs = Open_RsAndPageSize( conn, "select * from CASE_XS_1", session("test_rs"), 10 )
Else
Set rs = OpenOrGet_RsAndPageSize( conn, "select * from CASE_XS_1", session("test_rs"), 10 )
End If

Page = CLng(Request("Page")) ' CLng 不可省略
If Page < 1 Then Page = 1
If Page > rs.PageCount Then Page = rs.PageCount
%>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb_2312-80">
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
<title>分段浏览数据库的技巧</title>
</head>

<body>

<h2 align="center">PageBrow.asp - 分段浏览数据库的技巧</h2>

<hr align="center">
<%
ShowOnePage rs, Page
%>

<hr align="center">

<form action="PageBrow.asp" method="GET">
<%
If Page <> 1 Then
Response.Write "<A HREF=PageBrow.asp?Page=1>第一页</A>"
Response.Write "<A HREF=PageBrow.asp?Page=" & (Page-1) & ">上一页</A>"
End If
If Page <> rs.PageCount Then
Response.Write "<A HREF=PageBrow.asp?Page=" & (Page+1) & ">下一页</A>"
Response.Write "<A HREF=PageBrow.asp?Page=" & rs.PageCount & ">最后一页</A>"
End If
%>
</form>

<p>输入页数:<input type="text" size="3" name="Page"> 页数:<font color="#FF0000"><%=Page%>/<%=rs.PageCount%></font>
</p>

<p> </p>
</body>
</html>



onepage.asp

<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb_2312-80">
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
<title></title>
</head>

<body>
<%

Sub ShowOnePage( rs, Page )

Response.Write "<CENTER><TABLE BORDER=1>"
Response.Write "<TR BGCOLOR=#00FFFF>"
Response.WRITE "<TD>bh</TD>"
For i=0 to rs.Fields.Count-1
Response.WRITE "<TD>" & rs.Fields(i).Name & "</TD>"
Next
Response.Write "</TR>"

rs.AbsolutePage = Page
For iPage = 1 To rs.PageSize
Response.Write "<TR>"
RecNo = (Page - 1) * rs.PageSize + iPage
Response.Write "<TD>" & RecNo & "</TD>"
For i=0 to rs.Fields.Count-1
Response.WRITE "<TD>" & rs.Fields(i).Value & "</TD>"
Next
Response.Write "</TR>"
rs.MoveNext
If rs.EOF Then Exit For
Next
Response.Write "</TABLE></CENTER>"
End Sub

%>
</body>
</html>





util.asp
<%
Function OpenOrGet_Database( SessionName )

Dim conn

If Not IsObject(Session(SessionName)) Then
Set conn = Server.CreateObject("ADODB.Connection")
conn.Open "AJGL","case","why"
Set Session(SessionName) = conn
End If
Set OpenOrGet_Database = Session(SessionName)
End Function

Function OpenOrGet_RsAndPageSize( conn, sql, SessionName, PageSize )
Dim rs

If Not IsObject(Session(SessionName)) Then
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql, conn, adOpenStatic
Set Session(SessionName) = rs
rs.PageSize = PageSize
End If
Set OpenOrGet_RsAndPageSize = Session(SessionName)
End Function

Function Open_RsAndPageSize( conn, sql, SessionName, PageSize )
Dim rs

Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql, conn, adOpenStatic
Set Session(SessionName) = rs
rs.PageSize = PageSize
Set Open_RsAndPageSize = Session(SessionName)
End Function
%>
<html>

<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb_2312-80">
<meta name="GENERATOR" content="Microsoft FrontPage 3.0">
<title></title>
</head>

<body>
</body>
</html>


zigzag 2000-07-25
  • 打赏
  • 举报
回复
对于分页显示,那种数据库都是一样的方式,不知道你是不是连不上数据库。
用ADO连接,注意连接串的书写。你可以用ODBC方式,先建立你ORACLE数据库的ODBC,然后ADO连接串这样写:
"DSN=yourODBCname;UID=yourUserID;PWD=yourpassword;"
如果直接用Microsoft OLE DB Provider for Oracle,可以这样写:
"Provider=MSDAORA;Data Source=yourDataSource;User Id=yourUserID;PASSWORD=;DATABASE=yourDatabase".

请贴出你的代码!
netsong 2000-07-25
  • 打赏
  • 举报
回复
原则上,用odbc可连任何数据库(只需该数据库型的引擎,但效率会减低),原程序模式不用改变。
你用什么方法实现分页?
liuliushuang 2000-07-25
  • 打赏
  • 举报
回复
你的代码 ?

28,390

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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