Solved

Oledbdataadapter, doing a left outer join give an error

Posted on 2006-06-19
21
322 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

This article explains how to create and use a custom WaterMark textbox class.  The custom WaterMark textbox class allows you to set the WaterMark Background Color and WaterMark text at design time.   IMAGE OF WATERMARKS STEPS Create VB …
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

770 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