suppose we have 2 tables one containing records of student and other containing their subjects
we have 2 combo box one for students and other for their subjects
'''' giving value to first combobox
dataset ds = new dataset() ;
string querry = "select studentid,studentname from tbstudent";
sqlcommand cmd = new sqlcommand(querry,connection);
dataadapter da = new sqldataadapter(cmd);
combobox1.valuemember = "studentid";
combobox1.displaymember = "studentname";
combobox1.datasource = ds.tables(0);
now on combobox1 selected index event
dataset ds = new dataset() ;
string querry = "select subjectid,subjectname from tbsubject where studentid = combobox1.selectedvalue";
sqlcommand cmd = new sqlcommand(querry,connection);
dataadapter da = new sqldataadapter(cmd);
combobox2.valuemember = "subjectid";
combobox2.displaymember = "subjectname ";
combobox2.datasource = ds.tables(0);