I've created an Access database of 5 tables (personalData, WorkExperience, EducationalData, SpouseData, DependantData)
I have STHN_ID as primary key in the first table and as foreign key in the others. I also have a column named DateEngaged as Date/Time.
I try to select from PersonalData where STHN_ID=00001 and DateEngaged is within a Certain date range and it works fine. this is my code is
Dim rcmd As OleDbCommand = New OleDbCommand("Select STHN_ID FROM PersonalData WHERE ([STHN_ID]='" & STHN_ID.Text & "') and ([DateEngaged]>=CDate('" & FromDate.Value & "') AND [DateEngaged] <=CDate('" & ToDate.Value & "'))", myConnection)
My problem is after reading from PersonalData with those conditions and a record is found, it should go ahead and select all the fields in the other tables with that STHN_ID, that is, it should combine all columns in all the tables. the last thing I want to do is to read the combined columns to a datagridview.
So in the datagridview, I have all the columns from PersonalData, WorkExperience, EducationalData, SpouseData and Dependant data. so a row in the datagridview will contain all the records of that particular from the first table to the last table.
This is what I tried but it gives an error
da = New OleDbDataAdapter("Select * FROM [PersonalData] WHERE [STHN_ID]='" & STHNID.Text & "' AND ([DateEngaged]>=CDate('" & FromDate.Value & "') AND [DateEngaged]<=CDate('" & ToDate.Value & "' JOIN select * from EducationalData where STHN_ID='" & STHNID.Text & "' JOIN select * from WorkExperience where STHN_ID='" & STHNID.Text & "' JOIN select * from SpouseData where STHN_ID='" & STHNID.Text & "' JOIN select * from DependantData where STHN_ID='" & STHNID.Text & "'))", myConnection)