Description:
In the following cases, when a cursorType of adOpenStatic is requested, the resulting
recordSet will be opened with that cursor type:
adUseClient - adCmdText, or adCmdTable, or adCmdTableDirect
adUseServer - adCmdText, or adCmdTable
However a recordSet opened as adUseServer, adOpenStatic, adCmdTableDirect will result in
a forwardOnly recordSet
How to repeat:
Sub Test()
On Error Resume Next
Dim strSQL, oConn, oRs, vbSingleQuote, recordCount, curType
Set oConn = CreateObject("ADODB.Connection")
Set oRS = CreateObject("ADODB.RecordSet")
strSQL = "ado_test"
' open connection
oConn.ConnectionString = connstr
oConn.CursorLocation = adUseServer
Err.Clear
oConn.Open
If Err.Number <> 0 Then
Call Cleanup (oConn, oRs)
Assert.Trace Err.Number & "::" & Err.Description
On Error Goto 0
Assert.Failure "Error opening connection"
End If
' open record set
oRS.Open strSQL, oConn, adOpenStatic, adLockOptimistic, adCmdTableDirect
If Err.Number <> 0 Then
Call Cleanup (oConn, oRs)
Assert.Trace Err.Number & "::" & Err.Description
On Error Goto 0
Assert.Failure "Error opening Record Set"
End If
' Verify
If oRs.CursorType <> adOpenStatic Then
PrintType oRs.CursorType, curType
On Error Goto 0
Assert.Trace "Record Set opened as " & curType & " instead of adOpenStatic"
Call Cleanup (oConn, oRs)
Assert.Failure "Test Failed"
End If
Call Cleanup (oConn, oRs)
End Sub
Description: In the following cases, when a cursorType of adOpenStatic is requested, the resulting recordSet will be opened with that cursor type: adUseClient - adCmdText, or adCmdTable, or adCmdTableDirect adUseServer - adCmdText, or adCmdTable However a recordSet opened as adUseServer, adOpenStatic, adCmdTableDirect will result in a forwardOnly recordSet How to repeat: Sub Test() On Error Resume Next Dim strSQL, oConn, oRs, vbSingleQuote, recordCount, curType Set oConn = CreateObject("ADODB.Connection") Set oRS = CreateObject("ADODB.RecordSet") strSQL = "ado_test" ' open connection oConn.ConnectionString = connstr oConn.CursorLocation = adUseServer Err.Clear oConn.Open If Err.Number <> 0 Then Call Cleanup (oConn, oRs) Assert.Trace Err.Number & "::" & Err.Description On Error Goto 0 Assert.Failure "Error opening connection" End If ' open record set oRS.Open strSQL, oConn, adOpenStatic, adLockOptimistic, adCmdTableDirect If Err.Number <> 0 Then Call Cleanup (oConn, oRs) Assert.Trace Err.Number & "::" & Err.Description On Error Goto 0 Assert.Failure "Error opening Record Set" End If ' Verify If oRs.CursorType <> adOpenStatic Then PrintType oRs.CursorType, curType On Error Goto 0 Assert.Trace "Record Set opened as " & curType & " instead of adOpenStatic" Call Cleanup (oConn, oRs) Assert.Failure "Test Failed" End If Call Cleanup (oConn, oRs) End Sub