1
I’m having a little problem here and I haven’t found the solution yet, I’m loading data into a combobox using a DATASET from a INNER JOIN done in a database SQL SERVER. Until then it’s okay only that once I get the Cong, I’d like the other combobox to be blank...
I tried to put meucbx.Selectedindex = 0 in Load, I did not succeed
Follows 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
What is
cong
?– Marcus Vinicius