Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
'第三个参数:adOpenDynamic 动态
' adOpenForwardOnly 仅向前
' adOpenKeyset 键集
' adOpenStatic 静态
rs.Open strSQL, cn, adOpenDynamic, adLockReadOnly, adCmdText
Set rs = New ADODB.Recordset
'第三个参数:adOpenDynamic 动态
' adOpenForwardOnly 仅向前
' adOpenKeyset 键集
' adOpenStatic 静态
rs.Open strSQL, cn, adOpenDynamic, adLockReadOnly, adCmdText
.ActiveConnection = Conn
.CursorLocation = adUseClient
.CursorType = adOpenDynamic '动态游标
.LockType = adLockPessimistic
.Open 表名
end with
dim rs as adodb.recordset
set cn=new adodb.connection
set rs=new adodb.recordset
cn.open "dsn=你的数据源",adOpenDynamic,adLockReadOnly
rs=cn.excute(str)
一切OK
private cnADO as Connection
private mrsCon as adodb.recordset' Create the Connection object if it doesn't exist
If cnADO Is Nothing Then
Set cnADO = New Connection
' Set the Connection properties
With cnADO
.Provider = "SQLOLEDB"
.CommandTimeout = 7
.ConnectionTimeout = 10
.IsolationLevel = adXactReadCommitted
End With
End If' Connect if not already connected
If cnADO.State = adStateClosed Then
' Connect to the database
cnADO.Open "server=" & mstrServer & ";" & DATABASE, _
mstrUID, mstrPWD
End If
Set mrsCon = New Recordset
With mrsCon
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.LockType = adLockReadOnly
.CacheSize = 25
End With
mrsCon = cnADO.Execute(str)
mrsCon.movelast或mrsCon.moveprevious都可以。
以上都是用的ADO2。5+VB6。0
我仅仅设置cursortype,这样写对吗?Set rs = New adodb.Recordset
rs.CursorType = adOpenDynamic
Set rs = cn.Execute(strque)
你这么做是可以的。但不是很好,最好用楼上的几位的方法