Solved

Oledbdataadapter, doing a left outer join give an error

Posted on 2006-06-19
21
317 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
  • 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
 
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
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 

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 250 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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now