Retrieving multiple ID's from a query

Ugluth

Member
Joined
Sep 6, 2010
Messages
8
Programming Experience
Beginner
Hello there, I'm rather new to vb.net and also to the forum. I'm developing an application connecting to an access database. My project has 3 tables, one named students, one classes and one student_class. The first 2 keep information on students and classes respectively. The third one has only 3 fields, one for a registration id, one for a student id and one for a class id. There are foreign key relationships between them from the database.

What i want to do is have a combo box which will be displaying the list of available classes and once the user chooses the class he wants and presses the button i want the information of the students enrolled in that class to show up on a data grid. I've created the combo box showing all the classes, and i also have taken the id of the class that the user wants to display.

What i want to do now is get all the id's from the student_class table that match the id selected on the combo box and retrieve all the student id's that are on the same record with that id on the student_class table, and after wards i want to display some data of those students enrolled in the specified class and show their data on the data grid.

I'm using visual studio 2010 running on windows xp sp2 and using an access database with ending .mdb i'm not really sure which version it is, but its not the .accdb that access 2007 and onwards save it to.

Hope this post made some sense and thank you in advance. If you need any more information please do ask.
 
To be honest I'm not really into visual basic, i had taken a course back in college but that is 4 years ago and it was vb 6 not .net. Will give a look at the link and will also try it with the data table instead of the datagrid, thank you very much both for your time and help, you both are very kind!

Actually i am suggesting datatable instead DATASET and NOT datagrid. :)
 
Note that a dataset is simply a collection of datatables.. Datatables are devices that store data. And a datagrid is an old UI component that shows the data it finds in a datatable. DataGridView replaced DataGrid

Ugluth, this distinction should be very clear in your mind: DataGrids DO NOT HOLD DATA. When writing a database app that shows data in a grid control you will need at least a DataTabl, and a DataGridView, possibly also a dataset
 
Hmm I'm trying to do it the way cjard suggested, I've created a data set using the wizard and i created a form that inserts, edits and deletes with no sweat at all, just dragging and dropping and it works as well which is nice. Then i tried to create the query to filter students by which class they belong to. So i went through the data set editor and added a query on Student_Class table (I'm not really sure if that's the one i should be adding the query to).

I created my query and the results on the query builder where the ones i wanted. but then how do i make it so the results appear on a data grid as i wanted to initially? From a tutorial you pointed me to on your links, the Walkthrough: Creating a TableAdapter with Multiple Queries, i should do something like

VB.NET:
Student_ClassTableAdapter.FillByClass(AddressBookDataSet.Student_Class, 1)

but after that how do i put it in the datagrid? using addressbookdataset i'm guessing but could you please tell me a bit more exact? I'm a little confused with all these. Thank you very much
 
Back
Top