473,657 Members | 2,566 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to use an sql variable in a connect string to ORACLE

1 New Member
Hi,

I automated a process (using a recordable MACRO) in excell to open msaccess query and retrieve data (from an Oracle database) - said data then to be compared via VLOOKUP with data in a second worksheet

I then hoped to tinker with the recordable MACRO, so that the second time the query is made to the ORACLE database, a prompt asks for the unique key of the record to be retrieved. Hopefully, I'd like to amend the code further so that various connects are made to Oracle, the user queried for a record ID, the record returned and the data copy/paste specialed into excell.

The problem is I'm having trouble passing the variable across into ORACLE.

Perhaps you can help me?



- this defines the variable
Expand|Select|Wrap|Line Numbers
  1.    Dim DSETID As String       

- further down the code THIS takes the recordset ID
Expand|Select|Wrap|Line Numbers
  1.     DSETID = InputBox("Please input Dataset ID", "DATASET POPULATOR") 
- Connection with ORACLE is made. Unfortunately the DSETID doesn't appear to get passed across (see several lines down)
Expand|Select|Wrap|Line Numbers
  1.    Sheets("Data Warehouse").Select
  2.     Application.CutCopyMode = False
  3.     With Selection.QueryTable
  4.         .Connection = Array(Array( _
  5.         "ODBC;DRIVER={Oracle in OraHome92};SERVER=INETDEV.AUDIT-COMMISSION.GOV.UK;UID=acquire;;DBQ=INETDEV.AUDIT-COMMISSION.GOV.UK;DBA=W;APA=" _
  6.         ), Array( _
  7.         "T;EXC=F;XSM=Default;FEN=T;QTO=T;FRC=10;FDL=10;LOB=T;RST=T;GDE=F;FRL=Lo;BAM=IfAllSuccessful;NUM=NLS;DPM=F;MTS=T;MDI=Me;CSR=F;FWC" _
  8.         ), Array("=F;FBS=60000;TLO=O;"))
  9.         .CommandText = Array( _
  10.         "SELECT AUTHORITY.AUTHORITY_ID, AUTHORITY.SHORTNAME, DATASET.DESCRIPTION1, DATAGROUP.PERIOD, DATAGROUP.DESCRIPTION1, DATAVALUE.DATAVALUE" & Chr(13) & "" & Chr(10) & "FROM PROTO.AUTHORITY AUTHORITY, PROTO.AUTHORITYGROUP AUTHORITYG" _
  11.         , _
  12.         "ROUP, PROTO.DATAGROUP DATAGROUP, PROTO.DATASET DATASET, PROTO.DATAVALUE DATAVALUE" & Chr(13) & "" & Chr(10) & "WHERE AUTHORITYGROUP.AUTHORITYGROUP_ID = AUTHORITY.AUTHORITYGROUP_ID AND AUTHORITY.AUTHORITY_ID = DATAVALUE.AUTHORITY" _
  13.         , _
  14.         "_ID AND DATAVALUE.DATASET_ID = DATASET.DATASET_ID AND DATASET.DATAGROUP_ID = DATAGROUP.DATAGROUP_ID AND ((DATASET.DATAGROUP_ID= & DSETID))" _
  15.         )
  16.         .Refresh BackgroundQuery:=False
  17.     End With
  18.     Sheets("Data Template").Select
  19.     Range("G6:G12").Select
  20.     Selection.Copy
  21.     Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
  22.         :=False, Transpose:=False
  23.     ActiveWindow.ScrollColumn = 2
  24.     ActiveWindow.ScrollColumn = 1
  25. End 
- Help!!
Nov 29 '06 #1
0 1236

Sign in to post your reply or Sign up for a free account.

Similar topics

3
17868
by: David | last post by:
Hello all, I have been trying to use the OCI driver to connect to Oracle 9i, but have been getting the following error: java.sql.SQLException: Closed Connection at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134) at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179) at oracle.jdbc.oci8.OCIDBAccess.check_error(OCIDBAccess.java:2364) at oracle.jdbc.oci8.OCIDBAccess.logon(OCIDBAccess.java:480)
4
5198
by: Ellen K. | last post by:
Hi all, Being that so far I didn't get an answer to my below problem on the Oracle newsgroup, I figured it couldn't hurt to try here. While at my current job I've been working with mostly SQL Server, now I need to connect to our Oracle Financials running on HP-UX. The Oracle DBA set me up as a user and installed the Oracle client on my box and I have the tnsnames file, but I still can't establish a connection to the database from my...
0
2100
by: Ragtimer | last post by:
I've been trying to build a DAO.QueryDef.Connect string, building it from a user ID and password string obtained previously by a log-in dialog box, using it to log in to an Oracle database through an ODBC connection. The problem I have is that it's intermittent, in that invariably the first time I try to connect I still get the Oracle log-in prompt where the user has to type in all the info again anyway; and on subsequent connections...
1
15817
by: Hai Ly Hoang \(MT00KSTN\) | last post by:
Hi, I'm an Oracle newbie. I've just created a table in Oracle with CREATE TABLE. Now, in C#, how to connect to database and get my table ? Thanks
4
19845
by: RLN | last post by:
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.
7
4356
by: D. Patrick | last post by:
I need to connect to an Oracle database. I've never done it before. I see that with framework 1.1 you had to download ODP.NET from Oracle's site in order for the framework classes to even work. I tried that quickly, but the file is 400 MB, and the the installation asks for all kinds of things in order to install. Now I'm very confused. a) Do you still need ODP.NET with framework 2.0? b) Do you need to download and install other...
9
2407
by: D. Patrick | last post by:
I need to connect to an Oracle database. I've never done it before. I see that with framework 1.1 you had to download ODP.NET from Oracle's site in order for the framework classes to even work. I tried that quickly, but the file is 400 MB, and the the installation asks for all kinds of things in order to install. Now I'm very confused. a) Do you still need ODP.NET with framework 2.0? b) Do you need to download and install other...
0
1199
by: Francois Stander | last post by:
Hi, I am struggeling to connect to an Oracle db 10.2 through vb.net. Oracle client is installed on my maschine, Oracle.DataAccess in referenced in my app. this is how my code looks like: Dim oradb As String = "Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=57.24.110.z)(PORT=1521)))" _ + "(CONNECT_DATA=(SID = pegtest)))" _ + "User Id=xxx;Password=yyyy)" Dim conn As New...
15
6643
Zwoker
by: Zwoker | last post by:
Hi all, I am accessing data from an Oracle database via a connect string. I got into the situation where I wanted to write my SQL select statement to do a join between a local table sitting in my MS Access (2003) database, and an external Oracle table. But I realised I had no idea how to write the SQL. It appears that the whole SQL command gets passed to Oracle, not giving me any visibility to my local tables, is that correct? I know...
0
8392
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8305
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8825
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8605
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7324
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4302
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2726
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.