Hi everyone,
I know this is a very easy question for many of you people but I've been trying to solve it since yesterday and can't figure it out.
First, I have two tables 'Student_Module' (fields are StudID and ModID) and 'Module' (fields are ModuleName and ModuleID).
Say, I have a combo box in my form filled with student Id (I'm using VS2005).
What I'm trying to do is get the id from the combobox and use it to find the module names associated with that id from the module table. So, first I'm making query to the Student_Module table to find all ModuleIDs associated with the StudentID and then with that resultset looking into the Module table to find the module names.
The problem is I can't join these two statements into one sql command that will load the desired data into a datagrid.
Please help me if you can. I'm really helpless !
Thanks.
Edit : I tried the following code which I got from the MSAccess query wizard. It works but what I want to do is use studentid from the combobox and make the query.
I know this is a very easy question for many of you people but I've been trying to solve it since yesterday and can't figure it out.
First, I have two tables 'Student_Module' (fields are StudID and ModID) and 'Module' (fields are ModuleName and ModuleID).
Say, I have a combo box in my form filled with student Id (I'm using VS2005).
What I'm trying to do is get the id from the combobox and use it to find the module names associated with that id from the module table. So, first I'm making query to the Student_Module table to find all ModuleIDs associated with the StudentID and then with that resultset looking into the Module table to find the module names.
The problem is I can't join these two statements into one sql command that will load the desired data into a datagrid.
Please help me if you can. I'm really helpless !
Thanks.
Edit : I tried the following code which I got from the MSAccess query wizard. It works but what I want to do is use studentid from the combobox and make the query.
VB.NET:
SELECT Modul.ModuleName
FROM (Modul INNER JOIN Student_Modul ON Modul.ModuleId = Student_Modul.ModID) INNER JOIN Student ON Student_Modul.StudID = Student.Id
Last edited: