472,780 Members | 1,781 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,780 software developers and data experts.

Need to Connect to Oracle DB with no ODBC

RLN
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

*** Sent via Developersdex http://www.developersdex.com ***
Feb 24 '06 #1
4 19742
"RLN" <no****@devdex.com> wrote:
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.


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/de...asp?frame=true

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

http://tinyurl.com/8ct4k

-Mark
Feb 24 '06 #2
RLN wrote:
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.

--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Feb 24 '06 #3
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)

"RLN" <no****@devdex.com> wrote in message
news:_z***************@news.uswest.net...
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

*** Sent via Developersdex http://www.developersdex.com ***

Feb 25 '06 #4
>>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.

Feb 28 '06 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: simianphile | last post by:
OK, I had a problem that I've now fixed but I can't really understand what was causing it in the first place. I have an intranet site that uses basic authentication to allow users to view and...
0
by: Surly | last post by:
Both the Microsoft and the Oracle ODBC driver will take an outer join with the "{oj....}" ODBC syntax and Put the (+) on one column as determined by order of the columns in the "Left Outer Join"...
2
by: Miran Kopmajer | last post by:
I need Oracle ODBC Driver to convert database from MS access to Oracle 9i. Can anyone help me. Thx,Miran
0
by: Spiggy Topes | last post by:
Hi I have a Visual Basic application that uses ADO to access an Oracle database. I have the latest 9.x ODBC drivers installed, and SQL*Plus tells me I'm looking at Oracle 8i release 8.1.7.4.1...
1
by: Dave | last post by:
I'm trying to connect to an Oracle db on our network, through either SQL Server 2000 or Access 2000. Do I have to have Oracle client software loaded on my machine in order to do this or can I just...
5
by: SerGioGio | last post by:
Hello, I am going nuts. I am trying to connect to my local ORACLE instance using ODBC. It used to work few weeks ago, but it fails now. Connection with: - SQL*plus: connection works! -...
2
by: jmev7 | last post by:
Any way to avoid having to manually enter my user name & password for the Oracle login box? I normally run a query on an attached Oracle table and have to enter the un/pw before the query will run....
2
by: Crazy Cat | last post by:
Hi all, I am having trouble getting linked Oracle 9 server in MS SQL Server 2005 Express to work properly. My machine is running Windows XP. The Microsoft and Oracle OLE DB Providers have...
0
by: aparnats | last post by:
Hi, I need to connect to Oracle database from SQL Server. And for this, I was told to install Oracle ODBC driver. I downloaded Oracle ODBC Driver 9.0.1.8.0 and installed it (the installation was...
11
by: funky | last post by:
hello, I've got a big problem ad i'm not able to resolve it. We have a server running oracle 10g version 10.1.0. We usually use access as front end and connect database tables for data extraction....
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.