i have a combobox i want to show all the student name in it , i am using mssql database , and when we select student a textbox will show the rollno of that student , please help me

Recommended Answers

All 2 Replies

hello !
try this code , hope this will solve your prob.

Sub values()
        Dim con As New SqlConnection("connectionstring")
        Dim da As New SqlDataAdapter("select name , idno from students", con)
        Dim dt As New DataTable
        ComboBox1.DataSource = dt
        ComboBox1.DisplayMember = "name"
        ComboBox1.ValueMember = "idno"
    End Sub
'use this code at the selectedindex change event of your combobox
  TextBox1.Text = ComboBox1.SelectedValue.ToString()


thanks for this quick help , my prob is solved .

Be a part of the DaniWeb community

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