473,789 Members | 2,550 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

need join help

cj
My code below gives me "SQL: Column 'BTN' is not found."

It will work if I use an inner join or just join but those two joins
don't return all the rows. BTN has 5 rows, but arcust01 has only has
matching records for 2 of them. I need the other 3 returned with nulls
in the fields from arcust01.

How can I do this?

Imports System.Data.Ole Db

Public Class Form1
Dim myOleDbConnecti on As OleDbConnection
Dim myOleDbCommand As OleDbCommand
Dim myOleDbDataAdap ter As OleDbDataAdapte r

Dim dt As New DataTable

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
myOleDbConnecti on = New
OleDbConnection ("Provider=vfpo ledb.1;Data Source=c:\;Coll ating
Sequence=genera l")
myOleDbCommand = New OleDbCommand
myOleDbDataAdap ter = New OleDbDataAdapte r

Dim fields As String = "select btn.btn, arcust01.lastpa y,
arcust01.balanc e "
Dim from As String = "from btn outer join f:\chris\arcust 01
arcust01 on btn.btn = arcust01.custno "

myOleDbCommand. CommandText = fields & from
'myOleDbCommand .CommandText = "select btn.btn from btn"
myOleDbCommand. Connection = myOleDbConnecti on

myOleDbDataAdap ter.SelectComma nd = myOleDbCommand

myOleDbDataAdap ter.Fill(dt)

DataGridView1.D ataSource = dt
MessageBox.Show ("done!")
End Sub

End Class
Dec 13 '07 #1
2 1175
Hi Chris,

Based on my understanding, you have two database tables named 'BTN' and
'Arcust01'. The table 'BTN' has 5 rows in it and there're 2 rows in the
table 'Arcust01' matching 2 of the 5 rows in the table 'BTN'. What you want
is to query both two tables and return all the 5 rows in the table 'BTN'
among which the 3 rows not being matched returned with nulls in the fields
from the table 'Arcust01'. If I'm off base, please feel free to let me know.

You should use left outer join to get what you want. The following is a
sample:

Dim sQry As String = "select btn.btn, arcust01.lastpa y, arcust01.balanc e
from btn left outer join f:\chris\arcust 01 arcust01 on btn.btn =
arcust01.custno "

myOleDbCommand. CommandText = sQry

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.

Dec 14 '07 #2
cj
Thank you very much. That is exactly what I wanted.
Linda Liu[MSFT] wrote:
Hi Chris,

Based on my understanding, you have two database tables named 'BTN' and
'Arcust01'. The table 'BTN' has 5 rows in it and there're 2 rows in the
table 'Arcust01' matching 2 of the 5 rows in the table 'BTN'. What you want
is to query both two tables and return all the 5 rows in the table 'BTN'
among which the 3 rows not being matched returned with nulls in the fields
from the table 'Arcust01'. If I'm off base, please feel free to let me know.

You should use left outer join to get what you want. The following is a
sample:

Dim sQry As String = "select btn.btn, arcust01.lastpa y, arcust01.balanc e
from btn left outer join f:\chris\arcust 01 arcust01 on btn.btn =
arcust01.custno "

myOleDbCommand. CommandText = sQry

Hope this helps.
If you have any question, please feel free to let me know.

Sincerely,
Linda Liu
Microsoft Online Community Support

=============== =============== =============== =====
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
=============== =============== =============== =====

This posting is provided "AS IS" with no warranties, and confers no rights.
Dec 18 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3074
by: B. Fongo | last post by:
I learned MySQL last year without putting it into action; that is why I face trouble in formulating my queries. Were it a test, then you would have passed it, because your queries did help me solve my problem. I'll turn to MySQL doc after getting through this pressing project. Thanks a lot Roger! Babale -----Urspr=FCngliche Nachricht-----
9
3138
by: netpurpose | last post by:
I need to extract data from this table to find the lowest prices of each product as of today. The product will be listed/grouped by the name only, discarding the product code - I use SUBSTRING(ProductName, 1, CHARINDEX('(', ProductName)-2). I can get this result, but I had to use several views (totally inefficient). I think this can be done in one efficient/fast query, but I can't think of one. In the case that one query is not...
3
6418
by: Prem | last post by:
Hi, I am having many problems with inner join. my first problem is : 1) I want to know the precedance while evaluating query with multiple joins. eg. select Employees.FirstName, Employees.LastName, TerritoryID, Employees.EmployeeID, RegionID, ProductID from Employees
3
2222
by: ColdCanuck | last post by:
Help! I'm trying to understand the new ANSI join syntax (after many years of coding using the old style). I am now working with an application that only understands ANSI syntax so I am struggling. My first (old style syntax) SQL statement below produces 60 rows: SELECT A1.CONTACTID, A1.LASTNAME, A1.FIRSTNAME, A1.ACCOUNT, A6.CITY, A6.STATE, A1.WORKPHONE, A1.FAX, A1.EMAIL
3
10668
by: google | last post by:
I have a database with four table. In one of the tables, I use about five lookup fields to get populate their dropdown list. I have read that lookup fields are really bad and may cause problems that are hard to find. The main problem I am having right now is that I have a report that is sorted by one of these lookup fields and it only displays the record's ID number. When I add the source table to the query it makes several records...
3
1358
by: Danielle | last post by:
Hello group- I am having a problem where joined tables are returning too many rows. Here is my scenario - I am trying to create a temporary table from parts of three tables - the important columns are: a.id a.tran_date
2
4843
by: Terry Olsen | last post by:
I need to get information from 3 tables in an MDB file. I need all the columns in the first table. I need 2 columns in the 2nd table where it's primary key matches a column in the first table. I need several columns in the 3rd table where it's primary key matches a column in the 2nd table. I tried this:
1
1707
by: write2ashokkumar | last post by:
hi... i have the table like this, Table Name : sample Total Records : 500000 (Consider like this) Sample Records: id ------------ name
1
1549
by: write2ashokkumar | last post by:
hi... i have the table like this, Table Name : sample Total Records : 500000 (Consider like this) Sample Records: ----------------
2
1337
by: speavey | last post by:
When I run this query, I get an ORDER BY error "Incorrect syntax near the keyword 'ORDER'. I've bolded it below. If I take the ORDER by out then it works correctly, but I need the ORDER BY because of the TOP 9. Any Suggestions??? (SELECT TOP 9 trans.vchTrustee, trans.vchCaseNumber, Trans.TotalReceipts + SUM(a.mnyBalanceAmount) As Top9Total FROM tblCase c1 LEFT JOIN tblAsset a ON c1.intCaseID = a.intCaseID LEFT JOIN
0
9663
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10404
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10136
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9979
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9016
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6765
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5415
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4090
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2906
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.