944,161 Members | Top Members by Rank

Ad:
  • VB.NET Discussion Thread
  • Unsolved
  • Views: 11639
  • VB.NET RSS
You are currently viewing page 1 of this multi-page discussion thread
Aug 18th, 2007
0

Join multiple tables

Expand Post »
Hi there.
i'm having trouble joining tables. I'm using Access database. Initially, i have 2 tables called thresholdTable and Configuration. In the thresholdTable, there's a column called 'Config' and i've linked it to a column called 'Confuguration' from the Configuration table. Right now everything's working. However, i added another table, Consistency. I have a column in thresholdTable called 'Consistency' and i have to link it to 'Consistency' column from the Consistency table. How do i join 3 tables? Here's my codes:

Dim con As New OleDb.OleDbConnection
Dim ds As New DataSet
Dim da As New OleDb.OleDbDataAdapter
Dim sql As String

con.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Sowmya.mdb;Jet OLEDB:Database Password=geez"


con.Open()

sql = "SELECT * FROM thresholdTable INNER JOIN Configuration ON Configuration.Configuration = thresholdTable.Config"
da = New OleDb.OleDbDataAdapter(sql, con)
da.Fill(ds, "Sowmya")


con.Close()
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mustoora is offline Offline
23 posts
since Jul 2007
Aug 18th, 2007
1

Re: Join multiple tables

You can chain joins together and the next join works on the result of the last join.
VB.NET Syntax (Toggle Plain Text)
  1. SELECT *
  2. FROM thresholdTable INNER JOIN Configuration
  3. ON Configuration.Configuration = thresholdTable.Config INNER JOIN Consistency
  4. ON Consistency.Consistency = thresholdTable.Consistency;
The intermediate table that you join Consistency to is the result of joining thresholdTable and Configuration. If you wrap it in parentheses it's like this guy.
VB.NET Syntax (Toggle Plain Text)
  1. ((a INNER JOIN b ON a.col = b.col) INNER JOIN c ON c.col = a.col);
Reputation Points: 180
Solved Threads: 34
Posting Whiz
Hamrick is offline Offline
322 posts
since Jun 2007
Aug 18th, 2007
0

Re: Join multiple tables

I tried chain joins them together but i get an error. It says "Syntax error (missing operator) in query expression 'Configuration.Configuration = thresholdTable.Config INNER JOIN consistency ON consistency.consistency = thresholdTable.Consistency"
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mustoora is offline Offline
23 posts
since Jul 2007
Aug 18th, 2007
0

Re: Join multiple tables

Hi,

check this:

sql = "SELECT T.* FROM thresholdTable T, Configuration C Where  C.Configuration = T.Config"

Regards
Veena
Reputation Points: 84
Solved Threads: 140
Posting Shark
QVeen72 is offline Offline
923 posts
since Nov 2006
Aug 19th, 2007
0

Re: Join multiple tables

Then what about the consistency table? I also need to link the 'Consistency' column from thresholdTable to 'consistency' column from consistency table.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mustoora is offline Offline
23 posts
since Jul 2007
Aug 19th, 2007
0

Re: Join multiple tables

Hi,

Then give one more condition in where:

sql = "SELECT T.* FROM thresholdTable T, Configuration C Where  C.Configuration = T.Config And C.Consistency = T.Consistency"

u can give any number of equal conditions..

Regards
Veena
Reputation Points: 84
Solved Threads: 140
Posting Shark
QVeen72 is offline Offline
923 posts
since Nov 2006
Aug 19th, 2007
0

Re: Join multiple tables

Hi,

In case u have one more table, include that also in SQL Statement and give appropriate links..

Regards
Veena
Reputation Points: 84
Solved Threads: 140
Posting Shark
QVeen72 is offline Offline
923 posts
since Nov 2006
Aug 19th, 2007
0

Re: Join multiple tables

Hi..
I'm still facing some errors. It says No value given for one or more required parameters. By the way, my 'consistency' column is not from Configuration table. It's from another table called consistency. So actually i have 3 tables, thresholdTable, Configuration and consistency.

The relationship is like this:
Configuration.Configuration = thresholdTable.config,
consistency.consistency = thresholdTable.Consistency
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mustoora is offline Offline
23 posts
since Jul 2007
Aug 19th, 2007
0

Re: Join multiple tables

Hi,

Post the whole SQL Statement here. Such error occur when u have Mis-Spelled the Column Or Table Name.
I noticed it now Remove the Comma in the Relationship and give AND there. Check This:

Where Configuration.Configuration = thresholdTable.config And 
consistency.consistency = thresholdTable.Consistency
Reputation Points: 84
Solved Threads: 140
Posting Shark
QVeen72 is offline Offline
923 posts
since Nov 2006
Aug 20th, 2007
0

Re: Join multiple tables

Hi..
i'm still having errors. I added this statement:

sql = "SELECT * FROM thresholdTable Where Configuration.Configuration = thresholdTable.config And consistency.consistency = thresholdTable.Consistency"

It highlighted this code and says that no value is given for one or more required parameters.

Me.ThresholdTableTableAdapter.Fill(Me.SowmyaDataSet.thresholdTable)
Reputation Points: 10
Solved Threads: 0
Newbie Poster
mustoora is offline Offline
23 posts
since Jul 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in VB.NET Forum Timeline: AxMSCommLib.AxMSComm' is not defined
Next Thread in VB.NET Forum Timeline: time??





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC