?
Solved

Oledbdataadapter, doing a left outer join give an error

Posted on 2006-06-19
21
Medium Priority
?
332 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
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

Article by: Kraeven
Introduction Remote Share is a simple remote sharing tool, enabling you to see, add and remove remote or local shares. The application is written in VB.NET targeting the .NET framework 2.0. The source code and the compiled programs have been in…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses

850 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