Re: MS Access selecting from Oracle database

From: Ethan Post <post.ethan_at_gmail.com>
Date: Wed, 12 Mar 2008 17:01:16 -0500
Message-ID: <357b48a90803121501n5d205682q47b6716de7214d8e@mail.gmail.com>


Just an FYI for those interested. You can connect from Access without ODBC if you already have Oracle client installed and tnsnames configured. The code below is from a spreadsheet I am working on (I removed the excel stuff) but it would work in Access also if you want to code a connection to Oracle. You need to reference the ADO library from the references menu.

Public Sub TestMe()

   Dim cn As New ADODB.Connection
   Dim rs As New ADODB.Recordset
   Dim i As Long
   Dim sSQLQuery As String

   cn.Open "PROVIDER=OraOLEDB.Oracle;DATA SOURCE=PROD;USER ID=foo;PASSWORD=foo;"

   sSQLQuery = "select x, y, z from test_table;"

   rs.Open sSQLQuery, cn
   i = 1

   Do Until rs.EOF

      i = i + 1

      rs.MoveNext
   Loop

   rs.Close

End Sub

--
http://www.freelists.org/webpage/oracle-l
Received on Wed Mar 12 2008 - 17:01:16 CDT

Original text of this message