This code tries to display in listview fields of databases, but when he tries to show the part of the search he repeats previous data
Dim ds As DataSet = New DataSet
Dim sqlcon As MySqlConnection
Dim da As MySqlDataAdapter
If sqlcon.State = ConnectionState.Open Then
MsgBox("connected")
da = New MySqlDataAdapter("SELECT cod_funcionario, matricula, nome, cpf, rg, sexo, email, telefone, endereco, data_nasc, setor FROM funcionario", sqlcon)
da.Fill(ds, "funcionario")
Tabelas.Items.Clear()
If ds.Tables("funcionario").Rows.Count > 0 Then
For i As Integer = 0 To ds.Tables("funcionario").Rows.Count - 1
With Tabelas.Items.Add(ds.Tables("funcionario").Rows(i).Item(0).ToString)
.SubItems.Add(ds.Tables("funcionario").Rows(i).Item(1).ToString)
.SubItems.Add(ds.Tables("funcionario").Rows(i).Item(2).ToString)
.SubItems.Add(ds.Tables("funcionario").Rows(i).Item(3).ToString)
.SubItems.Add(ds.Tables("funcionario").Rows(i).Item(4).ToString)
.SubItems.Add(ds.Tables("funcionario").Rows(i).Item(5).ToString)
.SubItems.Add(ds.Tables("funcionario").Rows(i).Item(6).ToString)
.SubItems.Add(ds.Tables("funcionario").Rows(i).Item(7).ToString)
.SubItems.Add(ds.Tables("funcionario").Rows(i).Item(8).ToString)
.SubItems.Add(ds.Tables("funcionario").Rows(i).Item(9).ToString)
.SubItems.Add(ds.Tables("funcionario").Rows(i).Item(10).ToString)
End With
Next
End If
Else
The sql search doesn’t have a
whereclause, so it returns every row in funcionario. Is that your intention? Is the repeated data actually in the database?If the query is repeated in the same function, you might need a
ds.clearbefore the second query.