Ronok Bhowmik

Ronok Bhowmik

  • NA
  • 37
  • 30.6k

Show data in datagrid based on multiple tables

Feb 13 2014 1:59 PM
I have three tables named Names ,Departments and Students.The Names table contains columns named NameId and Name.NameId is the primary key.Here the input data for NameId is 1,2,3 and data for the Name are Ronok,Marsh and Priom accordingly. Then the table Departments contains the Column Names NameId,DepartmentId and the DepartmentName.Here DepartmentId is the primary key and NameId is the foreign key.Here the input data are 1,1,CSE ,2,2,EEE and soforth.The third table is the Students table.Here the column names are NameId and the DepartmentId.These two column are foreign key of Names and Departments table.
In the UI i have two comboboxes Named NamecomboBox and DepartmentCombobox.1stly when the form loads then the NameComboBox loads the Names from the Namestable and through the selection change event based of the namecomboBox the DepartmentComboBox populates.Now there is a Datagrid and a Button named Insert.When i press the insert button the data are inserted into the database table students as i mentioned earlier.Now i want to show the Name and the Department in the Datagrid.How can i do that.Thanks in advance.