Combobox come blank VB.NET with INNER JOIN

1

I have the problem here and I have not found the solution yet, I am loading data in a combobox using a DATASET from an INNER JOIN done in a database SQL SERVER . So far so good that as soon as I get the cong, I would like the other combobox to go blank ...

  

I have tried to put meucbx.SelectedIndex = 0 in Load, I did not succeed

Follow my code


//Listar as Congs listar_Cong vai para o Load


Private Sub listar_Cong()
        Using con As SqlConnection = CONECTA_DB()
            Try
                con.Open()
                Dim str As String = "SELECT * FROM sys_Config WHERE Status = 1"
                Dim cmd As SqlCommand = New SqlCommand(str, con)
                Dim dr As SqlDataReader
                dr = cmd.ExecuteReader
                While dr.Read
                    cbxCong.Items.Add(dr.Item("Nome")).ToString()
                End While
            Catch
               msgbox(Err.description)
            Finally
                con.Close()
            End Try
        End Using
    End Sub

   //Lista os usuarios com o INNER JOIN

  Private Sub listar_USUARIOS()
        Using con As SqlConnection = CONECTA_DB()
            Try
                con.Open()
                Dim str As String = "SELECT * FROM sys_Config" _
                                    & " INNER JOIN sys_Users"_
                                    & " ON (sys_Config .ID_CONG = sys_Users .ID_CONG)" _
                                    & " WHERE sys_Users.Status = 1"
                Dim da As SqlDataAdapter = New SqlDataAdapter(str, con)
                Dim ds As New DataSet
                da.Fill(ds)
                With cbxUsuarios
                    .DisplayMember = "Usuario"
                    .ValueMember = "ID_CONG"
                    .DataSource = ds.Tables(0).DefaultView
                End With
            Catch
                MessageBox.Show(Err.Description)
            End Try
        End Using
    End Sub
    
asked by anonymous 18.05.2015 / 00:26

2 answers

0

I was able to solve this with a code block error on my system. Thanks for the attempts!

//Era simplesmente locar isso cbxUsuarios.SelectedIndex = 0 //só que eles estava no local errado

    
21.05.2015 / 21:57
1

If you just want to clear ComboBox :

meucbx.Items.Clear()
    
18.05.2015 / 05:16