你可以把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
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>
对于分页显示,那种数据库都是一样的方式,不知道你是不是连不上数据库。
用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".