Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 1 / February 2006

Tip: Looking for answers? Try searching our database.

Need to Connect to Oracle DB with no ODBC

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
RLN - 24 Feb 2006 16:34 GMT
I have an Access2002 database that needs to connect to an Oracle
Database.  I connected to my Oracle DB in a simple VB6 app using no ODBC
data source.  How do I do the same thing using VBA in Access?

Below is the code I used in the VB app to connect to the Oracle
database, and I just can't seem to get it translated to ADO in
Access/VBA.

Any assistance is appreciated.

Here is the VB code that connects to Oracle with no OBDC:
<begin code>
Private Sub Form_Load()
Dim cnConn As Connection
Dim rsTemp As Recordset
Dim strDB As String, strTable As String, strMsg As String, strSQL As
String

strDB = "MyUniqueDB"
strlogin = "MyUniqueLogin"
strpass = "MyUniquePass"
strTable = "MyUniqueTable"

Set rsTemp = New Recordset
Set cnConn = New Connection
cnConn.ConnectionString = "Provider=OraOLEDB.Oracle.1;" & "Password=" &
strpass & "; User ID=" & strlogin & ";Data Source=" & strDB & "; Persist
Security Info=True"
cnConn.CursorLocation = adUseClient
cnConn.Open
   
strSQL = "SELECT Count(*) as results FROM " & strTable
       rsTemp.Open "SELECT Count(*) as results FROM " &
       strTable, cnConn, adOpenStatic, adLockReadOnly

Debug.Print "rsTemp!Results are: " & rsTemp!Results
Debug.Print "rsTemp.Recordcount is: " & rsTemp.RecordCount
   
rsTemp.Close
Set rsTemp = Nothing
End Sub
<end code>

RLN

----------
"Perseverance - there is no substitute for hard work."
 - Thomas Alva Edison
Tim Marshall - 24 Feb 2006 16:38 GMT
> I have an Access2002 database that needs to connect to an Oracle
> Database.  I connected to my Oracle DB in a simple VB6 app using no ODBC
> data source.  How do I do the same thing using VBA in Access?

You're using ADO in your code, something with which I'm not familiar.

My understanding is you cannot connect without ODBC (but see comments in
last para, below).  You can, in ADO, connect without a DSN, however.
But be warned - the ADO methods used to make such a connection are such
that you cannot use the reports in an mdb.

For DSNless connections, see
http://www.carlprothman.net/Default.aspx?tabid=81

This also has OLE DB provider connections, something I once investigated
a long time ago for connecting to Oracle via VB using Oracle's 0034 or
something OLE connector.  Not sure if this can be done in Access, maybe
some testing with connection on the string examples.  I would love to
hear if you're successful with it.

Signature

Tim    http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto  "TIM-MAY!!" - Me

Mark - 24 Feb 2006 16:56 GMT
>I have an Access2002 database that needs to connect to an Oracle
> Database.  I connected to my Oracle DB in a simple VB6 app using no ODBC
[quoted text clipped - 3 lines]
> database, and I just can't seem to get it translated to ADO in
> Access/VBA.

It sounds like you want to use ADO and oraOLEDB together?
I haven't done this, but a Google search turned up the following
which you might find helpful:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/ado270/htm/mdre
foracleprovspec.asp?frame=true


Here is a "tiny URL" link to the same MSDN page:

http://tinyurl.com/8ct4k

-Mark
david epsom dot com dot au - 25 Feb 2006 05:49 GMT
Access is VB.  Access has a different forms engine,
but it uses the same language engine.

I don't see anything wrong with the code you posted.
It looks like ordinary VB. It looks like it would
work in VB4,VB5,VB6,VBA5,VBA6.

The code you have posted does not require translation.
If it works in an VB environment, it works in VBA6,
which is bound into Access 2002.

Perhaps, you have not set your project references
correctly?  What project references are you using
in the project where the code does work?

(david)

>I have an Access2002 database that needs to connect to an Oracle
> Database.  I connected to my Oracle DB in a simple VB6 app using no ODBC
[quoted text clipped - 46 lines]
>
> *** Sent via Developersdex http://www.developersdex.com ***
TechBoy - 28 Feb 2006 23:03 GMT
>>You can, in ADO, connect without a DSN, however. <<
I don't think so.

Currently I have a connection string that works in code w/ ADO.
However when I made one little change to the TNSNames file then the
connection bombed.  Same happened when I would tweak the ODBC data
source.  So unless I'm missing something here, connecting to Oracle via
ADO requires ODBC & a TNSNames.ORA file and cannot be done with just
VBA code alone.

My goal here is simple.  Just trying to get away from having to load
and configure a TNSNames.ORA file and an ODBC data source on each
user's workstation.  I understand that the Oracle 8i client has to be
loaded on the user's workstation though.

I'm looking to just simply deploy my Access application to each
workstation minus the TNSNames/ODBC headaches.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.