Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 14th, 2008, 01:42 AM
Registered User
 
Join Date: Jul 2006
Posts: 7
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to sparsh2010
Default connection string to Oracle, Invalid Argument,err

Hi

I am trying to connect MS access to remote oracle 10g using connection string
__________________________________________________ _____
Problem and Error
__________________________________________________ _____

When the cursor comes to "Set objWkspace" as given below in Code it goes to
"Err_Handler:" Para
And the excat error is
Error : 3001
Invalid Argument

Note - there are no other error - the application stops at first error and I have no problem in connecting using ODBC ( ODBC is working fine)
__________________________________________________ _____
__________________________________________________ _____
TNSNAMES.ORA File has Entry as
__________________________________________________ _____
ORCL10G =
(DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(Host = 192.168.14.176)(Port = 1546))
    (CONNECT_DATA =
     (SERVER = DEDICATED)
     (SERVICE_NAME = orcl10g)
    )
)
__________________________________________________ _____

__________________________________________________ _____
Code Written as
__________________________________________________ _____

Private Sub Change_Click()

Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim StrORCL10G As String


On Error GoTo Err_Handler

'Build up the connection string
                                            
ODBCConnect = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOC OL=TCP)" & _
             "(HOST=192.168.14.176)(PORT=1546)))(CONNECT_ DATA=(SERVER=DEDICATED)" & _
             "(SERVICE_NAME=ORCL10G)));User Id=myUsername;Password=myPassword;"


'Use the DAO Workspace object to make the connection
        Set objWkspace = DBEngine.CreateWorkspace(ODBCConnect, bull, bull, dbUseODBC)

'Need to append it to make it active
        DBEngine.Workspaces.Append objWkspace

'Logon through a connection
     Set objOracleConnect = objWkspace.OpenConnection("objWkspace", dbDriverNoPrompt, False, _
     ODBCConnect)

     Set objRS = objOracleConnect.OpenRecordset("SELECT * FROM EMPLOYEE", _
             dbOpenDynamic, dbExecDirect, dbOptimisticValue)

Err_Handler:
Dim errLoop As Error

For Each errLoop In DBEngine.Errors
MsgBox "Error: " & errLoop.Number & vbCr & errLoop.Description, vbCritical, "Error Message"
Next errLoop

End Sub
__________________________________________________ __________________________________




Pramod Chandra
 
Old February 14th, 2008, 08:31 AM
Friend of Wrox
 
Join Date: Mar 2004
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

I don't think you can use DAO to connect to anything other than a Jet datasource. You need to use ADO to connect to Oracle and SQL Server. I use this code to establish a connection to Oracle:

Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim sSQL As String

Set cn = New ADODB.Connection
With cn
    .CursorLocation = adUseClient
End With
cn.Open "Provider=msdaora;Data Source=OracleServerName.DomainName;User ID=UserID;Password=password;"

sSQL = "SELECT * FROM OracleDatabaseName.TableName"

Set rs = New ADODB.Recordset
rs.Open sSQL, cn, adOpenDynamic, adLockOptimistic

etc.

Did that help any?


mmcdonal

Look it up at: http://wrox.books24x7.com





Similar Threads
Thread Thread Starter Forum Replies Last Post
oracle connection string in many databasee nandar_hayhay Oracle 1 July 4th, 2008 04:26 AM
Error msg: Invalid connection string attribute cJeffreywang ASP.NET 2.0 Basics 3 April 28th, 2008 11:40 AM
Oracle connection string asmaa ASP.NET 2.0 Professional 0 July 17th, 2007 05:42 AM
Invalid Connection String Attribute rstelma Classic ASP Databases 8 July 6th, 2005 06:31 PM
oracle connection string pankaj_daga Oracle 2 July 12th, 2004 03:43 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.