| | |
Join multiple tables
Please support our VB.NET advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Jul 2007
Posts: 23
Reputation:
Solved Threads: 0
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()
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()
You can chain joins together and the next join works on the result of the last join.
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)
SELECT * FROM thresholdTable INNER JOIN Configuration ON Configuration.Configuration = thresholdTable.Config INNER JOIN Consistency ON Consistency.Consistency = thresholdTable.Consistency;
VB.NET Syntax (Toggle Plain Text)
((a INNER JOIN b ON a.col = b.col) INNER JOIN c ON c.col = a.col);
The truth does not change according to our ability to stomach it.
Hi,
check this:
Regards
Veena
check this:
sql = "SELECT T.* FROM thresholdTable T, Configuration C Where C.Configuration = T.Config"Regards
Veena
Hi,
Then give one more condition in where:
u can give any number of equal conditions..
Regards
Veena
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
•
•
Join Date: Jul 2007
Posts: 23
Reputation:
Solved Threads: 0
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
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
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:
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•
•
Join Date: Jul 2007
Posts: 23
Reputation:
Solved Threads: 0
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)
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)
![]() |
Similar Threads
- generating one report from multiple tables (Visual Basic 4 / 5 / 6)
- Query multiple tables with duplicate data (MySQL)
- Searching for a record in multiple tables (VB.NET)
- Multiple Tables in a Database (Visual Basic 4 / 5 / 6)
- Delete from multiple tables (MySQL)
- Query multiple tables? (MySQL)
Other Threads in the VB.NET Forum
- Previous Thread: AxMSCommLib.AxMSComm' is not defined
- Next Thread: time??
| Thread Tools | Search this Thread |
.net .net2008 2005 2008 access account advanced application array basic beginner browser button buttons center click code combo cuesent data database datagrid datagridview date datetimepicker designer dissertation dissertations dissertationtopic dropdownlist excel exists fade filter forms ftp generatetags html images input insert intel internet listview mobile module monitor net number objects open panel passingparameters pdf picturebox picturebox2 port position print printing problem regex right-to-left save search searchvb.net select serial settings shutdown soap socket sqldatbase sqlserver survey temperature textbox timer timespan transparency trim txttoxmlconverter update user usercontol vb vb.net vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet visual visualbasic.net visualstudio.net visualstudio2008 web winforms wpf wrapingcode xml year





