473,385 Members | 1,185 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 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 19813
"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: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.