One type:
Sub test ()
'
'Test macro
'
Dim cn As ADODB. Connection
Dim rs As ADODB. Recordset
Set cn = New ADODB. Connection
Cn. Open "Provider = OraOLEDB. Oracle.1; PassWord = XXXX; Persist Security Info = True; User ID = XXXX; Data Source = XXXX; Extended Properties = PLSQLRSet = 1"
StrQuery = "select count (*) as rscount from staff"
Set rs = New ADODB. Recordset
Rs. Open strQuery, cn, adOpenStatic, adLockOptimistic
MsgBox rs ("rscount ")
End Sub
Another type:
Dim Con As New ADODB. Connection
Dim rst As New ADODB. Recordset
Dim Cmd As New ADODB. Command
Dim rsSQL As String
Dim PassId As Integer
Dim State As Integer
Dim Prm1 As New ADODB. Parameter
Dim Prm2 As New ADODB. Parameter
Con. ConnectionString = "Provider = OraOLEDB. Oracle.1; PassWord = cqboa; Persist Security Info = True; User ID = cqboa; Data Source = nsoa; Extended Properties = PLSQLRSet = 1"
Con. Open
RsSQL = "select t. aa from table t where t. No. =" & "5484"
With Cmd
. ActiveConnection = Con
. CommandType = ad1_text
. CommandText = rsSQL
End
Rst. CursorType = adOpenStatic
Rst. LockType = adLockReadOnly
Set rst. Source = Cmd
Rst. Open
Set PassId = rst. Fields ("no."). Value
Set State = 0
Set rst = Nothing
Set Cmd = Nothing
Con. Close