Advertisement

02.26.2008 at 05:41AM PST, ID: 23193409
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Pass-Through Query to Oracle via VBA in Access
Tags: Microsoft, Access, 2003, VBA
I can't seem to get pass-through queries to accept arguments from text boxes in forms.  Additionally, I have many queries and would like one location to change DSN/UID/Password info, rather than having to open up each pass-thru query and modify it.  Is it possible to send pass-thru queries to oracle via vba?  I would like a simple function/subroutine that accepts an oracle SQL statement as an argument.  I do not need it to return rows, as most of these calls will be to run a plsql procedure, but if returning rows is easy to do, then it may be useful...  Thanks!
Start your free trial to view this solution
Question Stats
Zone: Microsoft
Question Asked By: CalDude
Solution Provided By: Natchiket
Participating Experts: 1
Solution Grade: A
Views: 300
Translate:
Loading Advertisement...
02.26.2008 at 06:01AM PST, ID: 20984284

Rank: Wizard

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
02.26.2008 at 06:32AM PST, ID: 20984566

Rank: Wizard

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
02.26.2008 at 06:01AM PST, ID: 20984284

Rank: Wizard

Hi CalDude, it is certainly possible to send passthrough queries to Oracle via VBA.  As a passtrough query needs to comprise exclusively Oracle SQL, attempting to reference an Access form will prove fruitless since Oracle will not understand what is being referenced.

Here is an example some code which sends a passthrough query to oracle.  Hope you find it useful

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
Dim rst As DAO.Recordset
Dim qdf As DAO.QueryDef
Dim strConnect as string
 
...
 
'Pass through query
    'make the connect string
    'mstrDSN, mstrUID & mstrPWD are strings in my routine which contain the DSN
    'User ID and Password for the connection respectively
    strConnect = "ODBC;DSN=" & mstrDSN & ";UID=" & mstrUID & ";PWD=" & mstrPWD
    
     'retrieve the SQL
    'The system I am using stores the Oracle SQL in a Memo field in an Access table
    '(tblPassthroughQueries) when I need to use the query I retrieve the SQL from the table and
    'Substitute in values for the required parameters
    strSQL = "SELECT qOSQL FROM tblPassThroughQueries WHERE qName='" & mrst!sAction & "'"
    Set rst = mdb.OpenRecordset(strSQL, dbOpenSnapshot)
    
    strPTQ = rst(0)
    rst.Close
    Set rst = Nothing
    
    'Swap in  TimeKey criteria
    'Here a string called <TIMEKEY> is replaced with a date value (from mdatTK)
    strPTQ = Replace(strPTQ, "<TIMEKEY>", "'" & UCase(Format(mdatTK, "dd MMM yyyy")) & "'")
      'Some other replacements made here
    If InStr(1, strPTQ, "<RXMUPK>") > 0 Then
    'Swap in massive replacement clauses
        strPTQ = Replace(strPTQ, "<RXMUPK>", RXMP("ULTIMATEPARENTKEY"))
        strPTQ = Replace(strPTQ, "<RXMPK>", RXMP("PDH.PARTNERKEY"))
    End If
    
    'Create a temporay querydef
    'This is where we prepare to send the SQL to the server
    'Note that if you are not expecting to retrieve records you can set 
    'ReturnsRecords = False
     
    Set qdf = mdb.CreateQueryDef("")
    qdf.Connect = strConnect
    qdf.ReturnsRecords = True    
    qdf.ODBCTimeout = 0
    qdf.SQL = strPTQ
    
    'Retrieve records
    'Note for a non record retrieving statement use qdf.Execute
    Set rst = qdf.OpenRecordset(dbOpenSnapshot)
    qdf.Close
    Set qdf = Nothing
Open in New Window
 
02.26.2008 at 06:32AM PST, ID: 20984566

Rank: Wizard

Here's an example using a DSN less connection with ADODB ... in case it's more useful
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
Function TestPerms(strUID As String, strPWD As String, blnRW As Boolean, strErr As String) As Boolean
'------------------------------------------------------------------------------------------------------------------
'Tests whether the user has read write permission to a table
'strUID - user ID
'strPWD - password
'blnRW - test what should be RW table (if true), present what should be an RO table if false
'--------------------------------------------------------------------------------------------------------------------
 
Dim cn As ADODB.Connection
Dim lngRA As Long
Const DS1 = "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(PORT=1528)(HOST=xxxxxxx.xxx.xxxxxxx.com)))(CONNECT_DATA=(SERVICE_NAME=RRWU4)))"
'Const DS2 = "RRWU4"
 
Dim strCn As String
Dim strSQL As String
 
On Error GoTo proc_err
 
 
strCn = "Provider=OraOLEDB.Oracle;Data Source=" & DS1 & ";User Id=" & strUID & ";Password=" & strPWD & ";"
Set cn = New ADODB.Connection
 
If blnRW Then
    strSQL = "UPDATE CR_STRESSPORTFOLIOHIS SET PARTNERKEY='HELLO' WHERE 1=2"
Else
    strSQL = "UPDATE CR_PARTNERDETAILSHIS SET PARTNERKEY='HELLO' WHERE 1=2"
End If
 
cn.Open strCn
cn.Execute strSQL, lngRA
 
proc_exit_true:
TestPerms = True
 
proc_exit:
If Not cn Is Nothing Then
    Set cn = Nothing
End If
 
Exit Function
 
proc_exit_false:
TestPerms = False
GoTo proc_exit
 
proc_err:
strErr = Err.Description
Resume proc_exit_false
 
End Function
Open in New Window
Accepted Solution
 
 
02.26.2008 at 06:56AM PST, ID: 20984803
Thanks!  I modified it to the following.  Accepts a the query to be executed in oracle as a string, returns true or false.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
Function TestPerms(strSQL_PT_Query) As Boolean
Dim cn As ADODB.Connection
Dim lngRA As Long
Dim strCn As String
Dim DS1 As String
Dim strUID As String
Dim strPWD As String
Dim strPort As String
Dim strHost As String
Dim strTNS As String
 
strUID = "OP_DSS"     'Oracle user ID
strPWD = "dssopl"     'Oracle password
strPort = "1549"      'Oracle Server Port
strHost = "OHOSORP12" 'Oracle Server Hostname
strTNS = "HOPSPP"     'Oracle Instance Name
 
DS1 = "(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(PORT=" & strPort & ")(HOST=" & strHost & ")))(CONNECT_DATA=(SID=" & strTNS & ")))"
 
On Error GoTo proc_err
 
strCn = "Provider=OraOLEDB.Oracle;Data Source=" & DS1 & ";User Id=" & strUID & ";Password=" & strPWD & ";"
Set cn = New ADODB.Connection
 
cn.Open strCn
cn.Execute strSQL_PT_Query, lngRA
 
proc_exit_true:
TestPerms = True
 
proc_exit:
If Not cn Is Nothing Then
    Set cn = Nothing
End If
 
Exit Function
 
proc_exit_false:
TestPerms = False
GoTo proc_exit
 
proc_err:
strErr = Err.Description
Resume proc_exit_false
 
End Function
Open in New Window
 
 
02.26.2008 at 07:00AM PST, ID: 20984847
Great! Thanks for the points :)
 
 
 
20080236-EE-VQP-29 / EE_QW_2_20070628