最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
断开的数据库连接的一个例子
时间:2022-06-30 10:23:21 编辑:袖梨 来源:一聚教程网
使用断开的Recordset的一个关键条件就是使用客户端临时表,即
指定Rs.CursorLocation = adUseClient or 3,下面是一个完整
的例子:
demo-1.asp (在线演示:http://www.aspcn.com/demo/demo-1.asp)
------------------------------------------------------------
<%@ Language=VBScript %>
<%
'# -------------------------------------------------------------------
---------
'# 程序描述:演示使用断开的记录集
'# 程序设计:亚豪
'# -------------------------------------------------------------------
---------
On Error Resume Next
Dim adoConn,adoRs,SQLCmd,ConnectString
'#--------------------------------------------------------------------
---------
'# 使用SQL Server的 DSN-less 方式连接数据库
'#--------------------------------------------------------------------
---------
ConnectString = "Driver={SQL Server};" & _
"Server=(local);" & _
"Database=abc;" & _
"Uid=sa;" & _
"Pwd=123"
'#--------------------------------------------------------------------
---------
'# 创建对象实例,并初始化连接(Connection)
'#--------------------------------------------------------------------
---------
Set adoConn = Server.CreateObject("ADODB.Connection")
Set adoRs = Server.CreateObject("ADODB.Recordset")
adoConn.Open ConnectString
SQLCmd = "Select * from bbs_user where LTrim(RTrim(id)) = 'w3org'"
'#--------------------------------------------------------------------
---------
'# 使用客户端临时表打开并保存记录集,关键所在!
'# 客户端是运行ASP程序的主机,相对于数据库服务器而言
'#--------------------------------------------------------------------
---------
adoRs.CursorLocation = 3 'Const adUseClient = 3
adoRs.Open SQLCmd,adoConn,0,2
'#--------------------------------------------------------------------
指定Rs.CursorLocation = adUseClient or 3,下面是一个完整
的例子:
demo-1.asp (在线演示:http://www.aspcn.com/demo/demo-1.asp)
------------------------------------------------------------
<%@ Language=VBScript %>
<%
'# -------------------------------------------------------------------
---------
'# 程序描述:演示使用断开的记录集
'# 程序设计:亚豪
'# -------------------------------------------------------------------
---------
On Error Resume Next
Dim adoConn,adoRs,SQLCmd,ConnectString
'#--------------------------------------------------------------------
---------
'# 使用SQL Server的 DSN-less 方式连接数据库
'#--------------------------------------------------------------------
---------
ConnectString = "Driver={SQL Server};" & _
"Server=(local);" & _
"Database=abc;" & _
"Uid=sa;" & _
"Pwd=123"
'#--------------------------------------------------------------------
---------
'# 创建对象实例,并初始化连接(Connection)
'#--------------------------------------------------------------------
---------
Set adoConn = Server.CreateObject("ADODB.Connection")
Set adoRs = Server.CreateObject("ADODB.Recordset")
adoConn.Open ConnectString
SQLCmd = "Select * from bbs_user where LTrim(RTrim(id)) = 'w3org'"
'#--------------------------------------------------------------------
---------
'# 使用客户端临时表打开并保存记录集,关键所在!
'# 客户端是运行ASP程序的主机,相对于数据库服务器而言
'#--------------------------------------------------------------------
---------
adoRs.CursorLocation = 3 'Const adUseClient = 3
adoRs.Open SQLCmd,adoConn,0,2
'#--------------------------------------------------------------------
相关文章
- 《暖雪》慈母教圣文获取方式有哪些 06-16
- 《星球重启》伊甸城两连湾有哪些 06-16
- 《问剑长生》修士第一境界如何 06-16
- 《星球重启》进不去怎么解决 06-16
- 《异环》主要角色大全 06-16
- 《空之要塞:启航》赫山背景故事怎样 06-16