[FONT=Fixedsys]Option Explicit[/FONT]
[FONT=Fixedsys][/FONT]
[FONT=Fixedsys]Public Sub RunSQLqueryOracleDB()[/FONT]
[FONT=Fixedsys][/FONT]
[FONT=Fixedsys] Dim rsConn As ADODB.Connection
Dim strConnect As String
Dim rsData As ADODB.Recordset
Dim strSQL As String [/FONT]
[FONT=Fixedsys]
Set rsConn = New ADODB.Connection
strConnect = "DRIVER={[COLOR=red]Oracle in Ora9[/COLOR]};SERVER=[COLOR=red]servername[/COLOR];DBQ=[COLOR=red]databasename[/COLOR];UID=[COLOR=red]userid[/COLOR];PWD=[COLOR=red]password[/COLOR];" _
& "DBA=W;APA=T;EXC=F;XSM=Default;FEN=T;QTO=T;FRC=10;FDL=10;LOB=T;RST=T;" _
& "GDE=F;FRL=Lo;BAM=IfAllSuccessful;MTS=F;MDI=Me;CSR=F;FWC=F;PFC=10;TLO=O;"[/FONT]
[FONT=Fixedsys] rsConn.Open strConnect
If rsConn.State = 1 Then
MsgBox "Connection open" & Space(15), vbOKOnly + vbInformation
Else
MsgBox "Connection failed" & Space(15), vbOKOnly + vbExclamation
Exit Sub
End If
strSQL = "SELECT * FROM [COLOR=red]tablename[/COLOR];"
Set rsData = New ADODB.Recordset
rsData.Open strSQL, rsConn, 3, 1, 1
MsgBox rsData.RecordCount & " record" & IIf(rsData.RecordCount = 1, "", "s") _
& " found" & Space(15), vbOKOnly + vbInformation
rsData.Close
Set rsData = Nothing
Set rsConn = Nothing[/FONT]
[FONT=Fixedsys][/FONT]
[FONT=Fixedsys]End Sub[/FONT]