I use the following code to make an ADO connection to an Oracle
database. The connection is successful, but the query doesn't run. Any
help would be greatly appreciated.
Private Sub Form_Load()
' declaring the ADO connection
Dim conn As ADODB.Connection
'Dim cmd As ADODB.Command
Dim recset As New ADODB.Recordset
Set conn = New ADODB.Connection
'Set cmd = New ADODB.Command
' connection string needed to get to Oracle
conn.ConnectionString = "Driver={Microsoft ODBC for
Oracle};Server=oed1;UID=MyUsername;pwd=MyPassword"
' how long to wait before the connection dies
conn.ConnectionTimeout = 30
conn.Open
If conn.state = adStateOpen Then
' if the connection succeeds
MsgBox "Database Connection Successful...!"
Else
' if the connection doesn't work
MsgBox "Sorry, can't connect to the database"
End If
recset.Open "select * from employee where department<>'Manufacturing'
order by department, employeeid", conn
Do Until recset.EOF
picResults.Print recset!employeeid, recset!employeelast,
recset!employeefirst, recset!department, recset!teamid
recset.MoveNext
Loop
'MsgBox "all done"
recset.Close
conn.Close
Set recset = Nothing
Set conn = Nothing
'Set cmd = Nothing
End Sub