Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Oledbdataadapter, doing a left outer join give an error

Posted on 2006-06-19
21
Medium Priority
?
329 Views
Last Modified: 2012-08-14
How can I accomplish a left outer join with the Oledbdatadapter, I get an error when the statement is run !
0
Comment
Question by:ParanoidOne
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 11
  • 9
21 Comments
 
LVL 52

Expert Comment

by:Carl Tawn
ID: 16935012
What error ? Whats the code ?
0
 

Author Comment

by:ParanoidOne
ID: 16935041
I coughs up an error as soon as you leave the Query Designer, basically saying the statement will not work. I tried the same statement using the sqldataadapter and it does not work. It is something about Foxpro and the ODBC and OLEDB not allowing a left outer join.
0
 

Author Comment

by:ParanoidOne
ID: 16935044
I am sorry, type there. the SQLDataAdapter DOES allow the statement.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 96

Expert Comment

by:Bob Learned
ID: 16935101
What type of database are you accessing?

Bob
0
 

Author Comment

by:ParanoidOne
ID: 16935186
It is a set of DBF files, a directory containing about 10 of them. They are either Informix or Foxpro but normally the Foxpro setup seems to work fine, something like the OLEDbDataAdapter
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 16945298
Are you using the Visual FoxPro OleDb provider?

Bob
0
 

Author Comment

by:ParanoidOne
ID: 16945709
Yeah I have used both.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 16945832
What does the SQL statement look like?

Bob
0
 

Author Comment

by:ParanoidOne
ID: 16945979
Something like this, but the field names being different of course. This simple statement will run on the SQL adapter but not with the Oledb. The error is "Command contains unrecognized phrase/keyword.

SELECT     table1.id, table1.type, table2.descript
FROM         { oj table1 LEFT OUTER JOIN
                      table2 ON table1.type = table2.type }
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 16946044
Did you try it like this:

SELECT     table1.id, table1.type, table2.descript
FROM         table1 LEFT OUTER JOIN
                      table2 ON table1.type = table2.type

Bob
0
 

Author Comment

by:ParanoidOne
ID: 16946161
THe designer will pop the other characters back into the statement and still pop out an error.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 16946189
Does it run in the designer with those characters?

Bob
0
 

Author Comment

by:ParanoidOne
ID: 16946892
No.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 16953316
I'm sorry, I meant to say, "Does it run in the designer without those characters?"

Bob
0
 

Author Comment

by:ParanoidOne
ID: 16953572
Nope, I tried that too.
0
 

Author Comment

by:ParanoidOne
ID: 16953578
BTW I think it will require a UNION to work. From some reading Foxpro does not allow a LEFT OUTER JOIN
0
 
LVL 96

Accepted Solution

by:
Bob Learned earned 1000 total points
ID: 16953816
By George, you are correct:

Things Your Mamma Never Told You
http://www.hop.man.ac.uk/staff/mpitcher/foxpro/cdxf3.html

<Quote>
Oh no, it's the dreaded Left Outer Join! This is an SQL construct which FoxPro doesn't currently support, so you have to simulate it using a union of two selects: one for all the records with matches in table B, and one for all the records without. Here's an example:

      SELECT a.keyfield,;
            a.datafield1,;
            b.datafield2,;
            b.datafield3;
      FROM a,b;
      WHERE a.keyfield = b.keyfield;
      UNION;

      SELECT a.keyfield,;
            a.datafield1,;
            000.00,;
            000.00;
      FROM a;
      WHERE a.keyfield NOT IN;

      (SELECT b.keyfield;
            FROM b)

A Couple of points:
The numeric and string constants in the second select (000.00 in this example) have to exactly match the length of the fields in the second database, because FoxPro requires both sides of a union to exactly the same structure.

set relation to and set skip to may be faster and easier if it's only a simple query.
</Quote>

Bob
0
 

Author Comment

by:ParanoidOne
ID: 16954303
That is the website I read it on. Unfortunately his example does not seem to work for me, well it does work just not as intended for my purposes. I am still trying some stuff though.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 16960970
What kind of problems are you having with the UNION statement?

Bob
0
 

Author Comment

by:ParanoidOne
ID: 16962546
It appears to only give the information that is in both tables, instead of all of the information on the left. The end result I wanted was a left outer join.
0
 
LVL 96

Expert Comment

by:Bob Learned
ID: 16962568
That's where this comes into play:

SELECT a.keyfield,;
          a.datafield1,;
          000.00,;
          000.00;
     FROM a;
     WHERE a.keyfield NOT IN;
     (SELECT b.keyfield;
          FROM b)

Give me everything that is not in table b.

Bob
0

Featured Post

Tech or Treat! - Giveaway

Submit an article about your scariest tech experience—and the solution—and you’ll be automatically entered to win one of 4 fantastic tech gadgets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…
Suggested Courses

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question