| | |
Join multiple tables
Please support our VB.NET advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
![]() |
•
•
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 30minutes 2005 2008 access account arithmetic array basic beginner browser button buttons center check code component connectionstring crystalreport cuesent data database databasesearch datagrid datagridview date datetimepicker design designer dissertation dissertations dissertationtopic dropdownlist excel fade file-dialog filter folder forms ftp generatetags hardcopy html images input insert intel monitor net networking open output panel passingparameters peertopeervideostreaming picturebox picturebox1 port printing problem problemwithinstallation project reports" searchvb.net select serial settings shutdown sqlserver survey tcp temperature text textbox timespan toolbox transparency trim updown user usercontrol vb vb.net vb.netcode vb.netformclosing()eventpictureboxmessagebox vb2008 vbnet view visual visualbasic visualbasic.net visualstudio visualstudio.net visualstudio2008 web winforms wpf wrapingcode year





