ricaforrica
Programmer
Greetings!
I'm looking for a way of connecting Word with an Oracle database. The idea would be to press a button in a Word report and validate username and password from a table.
I've already inserted a table successfully with the InsertDatabase and MicrosoftQuery, but I need to implement a tranparent process to the end-user. So, only when they will press the button, the connection will be made. I believe a macro OnClick would be the better solution...
I tried using DAO objects with the following code:
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;UID=xxx;PWD=xxx;SERVER=server"
'Point to the current workspace
Set ws = DBEngine.Workspaces(0)
'Connect to Oracle
Set db = ws.OpenDatabase("", False, True, LConnect)
db.Close
OracleConnect = True
Err_Execute:
MsgBox "Connecting to Oracle failed."
OracleConnect = False
When I execute this, a dialog is opened so that I can choose the dataSource (DSN). I want the all process to execute without the user noticiing it, so I tried to define the DataSource:
LConnect = "ODBC;DSN=test;UID=xxx;PWD=xxx;SERVER=server"
But I get this error:
Runtime error 3151
ODBC--connection to 'test' failed
Why do I have to choose a datasource? The connection to the database isn't enough?
I also tried with Oracle Objects for OLE (OO4O), with the following code:
Dim OraSession As Object
Dim OraDatabase As Object
Dim OraDynaset As Object
On Error GoTo Err_Execute
Set OraSession = CreateObject("OracleInProcServer.XOraSession")
Set OraDatabase = OraSession.DbOpenDatabase("server", "user/pass", 1&)
MsgBox "Connected to " & OraDatabase.Connect & "@" & OraDatabase.DatabaseName
MsgBox "OO4O Version: " & OraSession.OIPVersionNumber
MsgBox "Oracle Version: " & OraDatabase.RDBMSVersion
Err_Execute:
MsgBox "Connecting to Oracle failed."
When I press the button nothing happens!
Can someone give me a hand on this???
Thanks in advance!
Ricardo Pinto
I'm looking for a way of connecting Word with an Oracle database. The idea would be to press a button in a Word report and validate username and password from a table.
I've already inserted a table successfully with the InsertDatabase and MicrosoftQuery, but I need to implement a tranparent process to the end-user. So, only when they will press the button, the connection will be made. I believe a macro OnClick would be the better solution...
I tried using DAO objects with the following code:
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;UID=xxx;PWD=xxx;SERVER=server"
'Point to the current workspace
Set ws = DBEngine.Workspaces(0)
'Connect to Oracle
Set db = ws.OpenDatabase("", False, True, LConnect)
db.Close
OracleConnect = True
Err_Execute:
MsgBox "Connecting to Oracle failed."
OracleConnect = False
When I execute this, a dialog is opened so that I can choose the dataSource (DSN). I want the all process to execute without the user noticiing it, so I tried to define the DataSource:
LConnect = "ODBC;DSN=test;UID=xxx;PWD=xxx;SERVER=server"
But I get this error:
Runtime error 3151
ODBC--connection to 'test' failed
Why do I have to choose a datasource? The connection to the database isn't enough?
I also tried with Oracle Objects for OLE (OO4O), with the following code:
Dim OraSession As Object
Dim OraDatabase As Object
Dim OraDynaset As Object
On Error GoTo Err_Execute
Set OraSession = CreateObject("OracleInProcServer.XOraSession")
Set OraDatabase = OraSession.DbOpenDatabase("server", "user/pass", 1&)
MsgBox "Connected to " & OraDatabase.Connect & "@" & OraDatabase.DatabaseName
MsgBox "OO4O Version: " & OraSession.OIPVersionNumber
MsgBox "Oracle Version: " & OraDatabase.RDBMSVersion
Err_Execute:
MsgBox "Connecting to Oracle failed."
When I press the button nothing happens!
Can someone give me a hand on this???
Thanks in advance!
Ricardo Pinto