How to populate a ComboBox based on another ComboBox using a connection string (SQL Server, VB.NET)

前端 未结 1 1582
庸人自扰
庸人自扰 2021-01-29 06:06

When a user selects a client from combobox 1 (a company we do work with and are partners with), its supposed to populate the users from combobox 2 for that client only, which ne

相关标签:
1条回答
  • 2021-01-29 06:21

    You just do what you have done in the load section in an if statement inside your user section.

    sort of like :

        `If cboClient.SelectedItem.Text = "Google" then
         (code to populate the other combobox with google info)
         End if`
    
    
         `If cboClient.SelectedItem.Text = "Yahoo" then 
            dim sql as string = "Select firstName+ " " +lastname as empName from 
            Yahoo table"
            dim cmd as sqladapter(sql, con)
            dim dt as datatable
            cmd.fill(dt)
            cboUsers.datasource = dt
            cboUsers.Datatextfield = "empName"
            cboUsers.Datavaluefield = "empName"
            cboUsers.DataBind()
         End if
    
    
            Dim sql2 As String = "Select EQPnumber, EQPdesc from CREW_LINEUP_ACTIVE_EQUIPMENT"
            Dim activeEQPadt As New SqlDataAdapter(sql2, IPMS.Settings.conn)
            activeEQPadt.Fill(activeDT)
            ActiveEQPLstBx.DataSource = activeDT
            ActiveEQPLstBx.DataTextField = "EQPdesc"
            ActiveEQPLstBx.DataValueField = "EQPnumber"
            ActiveEQPLstBx.DataBind()
    
    0 讨论(0)
提交回复
热议问题