?
Solved

Oledbdataadapter, doing a left outer join give an error

Posted on 2006-06-19
21
Medium Priority
?
328 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
Independent Software Vendors: 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

Independent Software Vendors: 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!

Question has a verified solution.

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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
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…
Suggested Courses

771 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