ASP中使用Oracle Object For Ole连接Oracle数据库

1、在global.asa中创建连接池
<script language=VBScript RUNAT="Server"> 'You can add special event handlers in this file that will get run automatically when 'special Active Server Pages events occur. To create these handlers, just create a 'subroutine with a name from the list below that corresponds to the event you want to 'use. For example, to create an event handler for Session_OnStart, you would put the 'following code into this file (without the comments): 'Sub Session_OnStart '**Put your code here ** 'End Sub 'EventName Description 'Session_OnStart Runs the first time a user runs any page in your application 'Session_OnEnd Runs when a user's session times out or quits your application 'Application_OnStart Runs once when the first page of your application is run for the first time by any user 'Application_OnEnd Runs once when the web server shuts down Sub Application_OnStart 'Get an instance of the Connection Pooling object and create a pool of OraDatabase OraConnection.CreateDatabasePool 1,40,200,"(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.8.6.205)(PORT=1521))(CONNECT_DATA=(SID=WYX)))", "bii/12345", 0 '| | |_ timeout seconds '| |_ max size '|_ init size End Sub Sub Session_OnStart Session.Timeout=60 Server.ScriptTimeout=999999 set Session("OraDataBase")=OraConnection.GetDatabaseFromPool(10) '|_ wait time seconds MPSInit() End Sub Sub Session_OnEnd set Session("OraDataBase")=nothing End Sub Sub Application_OnEnd OraConnection.DestroyDatabasePool End Sub </script> <OBJECT RUNAT=Server SCOPE=Application ID=OraConnection PROGID="OracleInProcServer.XOraSession"></OBJECT>
<SCRIPT LANGUAGE=VBScript RUNAT=Server>
Sub Application_OnStart
     'Get an instance of the Connection Pooling object and create a pool of OraDatabase     OraConnection.CreateDatabasePool 1,40,200,"(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=10.8.6.205)(PORT=1521))(CONNECT_DATA=(SID=WYX)))", "bii/12345", 0 '
    '1-----init pool size
    '40---max pool size
    '200-timeout seconds
 End Sub

Sub Session_OnStart
    Session.Timeout=60
    Server.ScriptTimeout=999999
    set Session("OraDataBase")=OraConnection.GetDatabaseFromPool(10) '
    '10----wait time seconds
 End Sub

Sub Session_OnEnd
    Session("OraDataBase").Close
    set Session("OraDataBase")=nothing
End Sub

Sub Application_OnEnd
    OraConnection.DestroyDatabasePool
End Sub
</SCRIPT>
2、在其它页面中进行引用
dim OraDynaset,sql
sql="select * from tablename"
set OraDynaset=Session("OraDataBase").DbCreateDynaset(sql,0)
do while not OraDynaset.Eof
    ……
    OraDynaset.DbMoveNext
loop


事务用法:
Session("Oradatabase").BeginTrans
Session("Oradatabase").RollBack
Session("Oradatabase").CommitTrans

注:在WEB服务器上在确保安装有ORACLE客户端组件------》Oracle Object For OLE

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值