Sorry but I did not know what "(Host=o"") should be, so I just dropped the oh...
Main Topics
Browse All TopicsUsing a DSNLess connection to an Oracle Dataview and access the data w/o using temp table.
Is there a way to access an Oracle dataview using DSN-Less Connection and being able to view the data w/o actually creating a temp table?
As you can see '********************* I tried using to create/.append Access table but run into type mismatch isssues.
If I do not need to create the temp table but still view the data would be my preference.
Any ideas?
K
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
When you say "view the data", what are you using to view it? If this is a Form, you can build your ADO recordset and set your form to that recordset like this:
Set Me.Recordset = YourRecordsetObject
Assuming your have controls on that form that correspond to the fields in the recordset, you'd see your data.
Nevertheless, if you want to use the code as you supplied, try specifying the order of your columns in the rs recordset, instead of using SELECT *:
strSQL = "Select Col1,Col2,Col3 etc from tblFTIR_vw"
rs.Open strSQL, cn, adOpenDynamic, adLockOptimistic
Another issue is the data type conversion between oracle and Access, has displayed in my code I tried setting the field values via a loop statement.
but ran into the data type conversion issue.
What about make table type of code to set the field names and field datatypes, values, etc. Know of any code that might do that.
k
<Will this statement actual open a query and display the results?>
No ... this opens a recordset, which is sort of like an "in memory". Once you open a Recordset, you would then do something with it (like loop through it and set a value in one of the fields, or perhaps use it to manipulate data in another recordset). In your case, if you want to see it in something like a query or datasheet view, you'd probably be better off dumping it to a temporary table.
As to datatype conversions ... this can be difficult, since Oracle (or any other server-type database) will have datatypes which aren't compatible with Access. It appears that Oracle BLOB/CLOB/NCLOB/NCHAR columns can cause problems coming into Access; I'm not sure of the workaround for them.
You could also build a form that would show this and set the Form's Recordset to the ADO Recordset you create. Just build your form (add the textboxes and set their Tag property to "d"; don't bind them), then open your Oracle recordset. Bind the controls on your form like this:
Dim rst As ADODB.Recordset
<build your connection and ADO Recordset>
Dim i As integer
Dim j As Integer
For i = 0 To Me.Controls.Count -1
If Me.Controls(i).Tag = "d" Then
Me.Controls(i).ControlSour
j = j +1
End If
Next i
Set Me.RecordSet = rst
Assuming you have the same number of controls as you do Recordset fields, this would work. Set the Form to Continuous or Datasheet view and you'll see all the values in that recordset.
Running a SELECT INTO query like this would build the table on the ORACLE db and not on the Access db (since you've connected to the Oracle db via the adoConn object).
I'm not sure of the error, however you have 2 DateCreated fields in this query ... also, do away with the Environ() call, and use Single Quotes if FTIR_APNO is a Text value:
Dim sUser As String
sUser = Environ("UserName")
strSQL = "SELECT FTIR_MEASNO, FTIR_APNO, FTIR_TITLE, FTIR_RM, FTIR_SPS, FTIR_MIN, FTIR_MAX, FTIR_UNITS," & _
" FTIR_ACC, FTIR_TYPE, FTIR_LOC, FTIR_FLTR, FTIR_HCO, FTIR_LCO, FTIR_BUSNAME, FTIR_SU, FTIR_EU_SU," & _
" FTIR_EU, FTIR_SPHDL, FTIR_DESC, FTIR_MAINTCD, FTIR_CMT, FTIR_INSTLDWGNO, FTIR_LAST_REVISOR," & _
" FTIR_LAST_REVISION_DATE, Date as DateCreated," & sUserName & "AS [User], Now() AS DateCreated" & _
" INTO tblFTIR_vw" & _
" FROM FTCSVERF.FTIR_DNLD_VI_VW" & _
" WHERE FTIR_APNO='" & UCase(gAPNo) & "'"
Found this on the web - not sure how it applies to my code. Maybe the syntax for Oracle to create a table is different from Access.
ORA-00936: missing expression
Cause: A required part of a clause or expression has been omitted. For example, a SELECT statement may have been entered without a list of columns or expressions or with an incomplete expression. This message is also issued in cases where a reserved word is misused, as in SELECT TABLE.
Action: Check the statement syntax and specify the missing component.
Now I trying to execute the oracle portions separately, however, How do i incorporate these results within the Access sql
strSQL = "SELECT FTIR_MEASNO, FTIR_APNO, FTIR_TITLE, FTIR_RM, FTIR_SPS, FTIR_MIN, FTIR_MAX, FTIR_UNITS," & _
" FTIR_ACC, FTIR_TYPE, FTIR_LOC, FTIR_FLTR, FTIR_HCO, FTIR_LCO, FTIR_BUSNAME, FTIR_SU, FTIR_EU_SU," & _
" FTIR_EU, FTIR_SPHDL, FTIR_DESC, FTIR_MAINTCD, FTIR_CMT, FTIR_INSTLDWGNO, FTIR_LAST_REVISOR," & _
" FTIR_LAST_REVISION_DATE" & _
" FROM FTCSVERF.FTIR_DNLD_VI_VW" & _
" WHERE FTIR_APNO='ZA001'" '" & UCase(gAPNo) & "'"
Set adoRS = New ADODB.Recordset
adoRS.Open strSQL, adoConn, adOpenDynamic, adLockReadOnly
CurrentDb.Execute "SELECT FTIR_MEASNO, FTIR_APNO, FTIR_TITLE, FTIR_RM, FTIR_SPS, FTIR_MIN, FTIR_MAX, FTIR_UNITS," & _
" FTIR_ACC, FTIR_TYPE, FTIR_LOC, FTIR_FLTR, FTIR_HCO, FTIR_LCO, FTIR_BUSNAME, FTIR_SU, FTIR_EU_SU," & _
" FTIR_EU, FTIR_SPHDL, FTIR_DESC, FTIR_MAINTCD, FTIR_CMT, FTIR_INSTLDWGNO, FTIR_LAST_REVISOR," & _
" FTIR_LAST_REVISION_DATE, Date as DateCreated, Environ$('Username')AS [User]" & _
" INTO tblFTIR_vw" & _
" FROM (SELECT FTIR_MEASNO, FTIR_APNO, FTIR_TITLE, FTIR_RM, FTIR_SPS, FTIR_MIN, FTIR_MAX, FTIR_UNITS," & _
No need to shout ... sorry you're having troubles, but it ain't my fault.
Can you create a linked table? If so, you could use it just as you would a local table. Otherwise, in order to view the data you'd need to create some form of "physical" object (form, report, etc) that would enable you to view the data onscreen.
If you must use a DSN-less connection, then you'll have to create a table of some sort. You could open your recordset to the Oracle db, then just loop through and use INSERT INTO to push the data into a local table. You'd have to build the table first, of course, but assuming you have that table built:
<open your recordset>
Do until rst.EOF
Currentproject.Connection.
rst.MoveNext
Loop
Of course, if these are Text values, you'll need to enclose them in single quotes; if Dates, enclose them in hash marks.
Well, you'd need to determine what FieldTypes are coming in from Oracle and make sure those fields are going into valid FieldTypes in your Access tables. Here's a KB article that may help: http://support.microsoft.c
Why would you need to pass a parameter to an Oracle table? Or are you running this against a Stored Procedure (or whatever they call them in Oracle)?
Here are the Oracle table fields & field types The FTIR_Measno is normally a Text field w/i Access. Do you suggest I convert during the update of the table, or change the FTIR_MeasNO in my temp table to a number, then convert it to a CVar("FTIR_MEASNO") when I go to use it in the newly creaed temp table?
Column Name ID Data Type Null?
FTIR_MEASNO 1 NUMBER (7) (ACcess has it as text field) N
FTIR_APNO 2 VARCHAR2 (8 Char) N
FTIR_TITLE 3 VARCHAR2 (24 Char) Y
FTIR_RM 4 VARCHAR2 (2 Char) Y
FTIR_SPS 5 NUMBER (8,2) Y
FTIR_MIN 6 VARCHAR2 (7 Char) Y
FTIR_MAX 7 VARCHAR2 (7 Char) Y
FTIR_UNITS 8 VARCHAR2 (6 Char) Y
FTIR_ACC 9 FLOAT Y
FTIR_TYPE 10 VARCHAR2 (4 Char) Y
FTIR_LOC 11 VARCHAR2 (4 Char) Y
FTIR_FLTR 12 VARCHAR2 (3 Char) Y
FTIR_HCO 13 FLOAT Y
FTIR_LCO 14 FLOAT Y
FTIR_BUSNAME 15 VARCHAR2 (8 Char) Y
FTIR_SU 16 VARCHAR2 (6 Char) Y
FTIR_EU_SU 17 FLOAT Y
FTIR_EU 18 FLOAT Y
FTIR_SPHDL 19 VARCHAR2 (1 Char) Y
FTIR_DESC 20 VARCHAR2 (240 Char) Y
FTIR_MAINTCD 21 VARCHAR2 (1 Char) N
FTIR_CMT 22 VARCHAR2 (240 Char) Y
FTIR_INSTLDWGNO 23 VARCHAR2 (14 Char) Y
FTIR_LAST_REVISOR 24 VARCHAR2 (6 Char) Y
FTIR_LAST_REVISION_DATE 25 DATE Y
Still having issues with the Accessors Error: I know it is not the Parameter issue it is the syntax issue. based on the table structure previously mentioned could you verify my syntax. when I attempt to limit my query to figure out which field is causing the problem I am getting a Missing expression error and when I leave it intact I get the Accessors Error.
You don't have an ending single quote on the last item:
adoRS("FTIR_LAST_REVISOR")
Format(adoRS("FTIR_LAST_RE
--------------------------
Also, is FTIR_Last_Revision_Date a Date field or a Text field? If it's a Date field, try surrounding it with hash marks ( # ).
Note that you can normally check your syntax pretty easily by "running" it in the Immediate window, then copy/paste the SQL into a new, blank query ... then switch to design view and Access will often tell you what (and where) the problem lies. To run the sql, just copy eventhing from the "INSERT INTO (including the double quote) and paste it into the Immediate window, add a ? before the whole thing then press enter ... the immediate window will show you the resultant string which you can then paste into a blank query for testing.
Yes, I tried your suggestions, and I am still getting type mismatch issues, when it comes to the Null values.
I cam across the follwoing function - is there a way to convert this to use the DSN-less type of connection string.
Also coulld I use a QueryDef type of code to actual view the data without using an updating of table - which causes the issue with datatype conversions?
Function fPassThrough(strSQL As String, strDSN)
Dim db As Database
Dim qdf As QueryDef
Set db = CurrentDb
Set qdf = db.CreateQueryDef("", strSQL)
With qdf
.ReturnsRecords = False
.Connect = "ODBC;DSN=" & strDSN
.Execute
.Close
End With
End Function
You can try setting the Connect setting to a valid connect string ... you might also be able to simply view the data as well by just opening your query.
For info on connect strings try www.connectionstrings.com
<Yes, I tried your suggestions, and I am still getting type mismatch issues, when it comes to the Null values.>
Anytime you are working with potential Null values you'll need to handle them ... in Access, the easiest way is to use the Nz function on EACH column:
"INSERT INTO tblFTIR_vw(FTIR_MEASNO, FTIR_APNO, FTIR_TITLE, FTIR_RM, FTIR_SPS, FTIR_MIN, FTIR_MAX, FTIR_UNITS," & _
" FTIR_ACC, FTIR_TYPE, FTIR_LOC, FTIR_FLTR, FTIR_HCO, FTIR_LCO, FTIR_BUSNAME, FTIR_SU, FTIR_EU_SU," & _
" FTIR_EU, FTIR_SPHDL, FTIR_DESC, FTIR_MAINTCD, FTIR_CMT, FTIR_INSTLDWGNO, FTIR_LAST_REVISOR," & _
" FTIR_LAST_REVISION_DATE) " & _
" VALUES('" & Nz(adoRS("FTIR_MEASNO"),''
"'," & LTrim$(Nz(adoRS("FTIR_TITL
When I tried the Nz(), still got the same error, I even tried Nz(fieldName),0) around those fields that = numbers. Still no luck.
Trying different approach - changing the insert into an existing table - I am attempting to Create TAble on the fly with the Oracle Table using the fPassThrough Code. Having some connection issues, maybe you could assist me and is this a feasible way to approach the datatype conversion issues? Which would you recommend?
k
<Edited by AnnieMod to remove sensitive information>
I think you'd be much better off working through the datatype issues. There are plenty of apps out there that connect to Oracle databases, so the problem is certainly not insurmountable, you just need to pinpoint where the problem lies. This is most easily done by working through the fields 1 by 1 - add the FIRST field to your insert syntax and run that ... then add another field, then another, and execute after EACH of those. Find out where the code fails and fix that, then move on from there.
Business Accounts
Answer for Membership
by: BadotzPosted on 2007-12-28 at 14:23:04ID: 20545689
Your connection string is invalid:
Data Source=(DESCRIPTION=(ADDRE SS_LIST=(A DDRESS=(PR OTOCOL=TCP )" & _ NECT_DATA= (SID=ftcsv erf)));" & _
Data Source=(DESCRIPTION=(ADDRE SS_LIST=(A DDRESS=(PR OTOCOL=TCP )" & _ CONNECT_DA TA=(SID=ft csverf))); " & _
sConn = "Provider=OraOLEDB.Oracle;
"(Host=o"")(Port="")))(CON
"User Id="";Password='';"
Too many quotes inside quotes, for one thing.
sConn = "Provider=OraOLEDB.Oracle;
"(Host="""")(Port="""")))(
"User Id="""";Password="""";"
might help, or you could replace all of the " " " " with ' ' and see if that helps