Connect to Oracle from access (Programmatically)
Hi,
I just found a sample code how to connect to Oracle from access, but it always give me an error msg said connection failed.
This is my code looks like. It always go to the connection failed. Can anyone help me pls?
appreciate it any help thx.
Function OracleConnect() As Boolean
Dim ws As Workspace
Dim db As Database
Dim LConnect As String
On Error GoTo Err_Execute
'Use {Microsoft ODBC for Oracle} ODBC connection
LConnect = "ODBC;DSN=hrdevl;UID=ma_user;PWD=password;SERVER=perdv02"
'Point to the current workspace
Set ws = DBEngine.Workspaces(0)
'Connect to Oracle
Set db = ws.OpenDatabase("", False, True, LConnect)
db.Close
OracleConnect = True
Exit Function
Err_Execute:
MsgBox "Connecting to Oracle failed."
OracleConnect = False
End Function