I have two fields in a table(dept_code and DEPT_name) in SQL.In my form iam having two comboboxs. one for dept_name and the other for Dept_code.What i want is that when i select a particular dept_name from the combobox its associated dept_code should come in the other combobox????

After assign ComboBox your datasource (your department table) navigate in ComboBox properties you'll find which help you doing your task.

Hi You Must try this

Protected Sub DropDownList1_SelectedIndexChanged()
  con=new sqlcnnection(constr)
  adpt=new sqldataadapter("select dept_code  from T.N. where dept_name='"+dropdownlist1.selecteditem+"'",con)
  ds=new dataset
  adpt.fill(ds,"T.N.")
  dim i as string=ds.tables(0).rows(0).item(0)
  dropdownlist2.item.clear()
  dropdownlist2.item.add(i)
End Sub
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.