-1
I’m trying to capture some information from the database, filter it and then run validation tests on each of the returned lines. Then I try to take the lines that failed the test and insert them into a new datatable. However, after having the datatable filled in and having it associated with datagridview as a datasource, the data does not appear in the datagridview object.
What can it be?
Dim Aviso As New frmWarning
Dim Filtros As String
Dim DtTable As New DataTable
Dim DtView As DataView
Aviso.Abrir()
Filtros = "Data >= '" & DtInicial.Text & "'"
Filtros = Filtros & " and Data <= '" & DtFinal.Text & "'"
Filtros = Filtros & " and Loja = " & Me.cmbLojas.SelectedValue
With dgvCPF
.AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.AllCells
.DataSource = Nothing
.ColumnCount = 7
.Columns(0).Name = "TipoDaNota"
.Columns(0).DataPropertyName = "TipoDaNota"
.Columns(1).Name = "CPF_CNPJ"
.Columns(1).DataPropertyName = "CPF_CNPJ"
End With
If NotasTable.Rows.Count = 0 Then
DtTable = preencheNotasImp() 'Retorna Busca de Dados
DtView = New DataView(DtTable)
DtView.RowFilter = Filtros ' Filtra os dados
Dim CGC As String
Dim DtAux As New DataTable
DtTable = DtView.ToTable 'Retorna os dados filtrados para a antiga datatable
For Each Row As DataRow In DtTable.Rows
CGC = Row.Item(9).ToString()
If ValidaCGCCPF.Validations.isCNPJ(CGC) = True Or _
ValidaCGCCPF.Validations.isCPF(CGC) = True Then
DtAux.ImportRow(Row) 'Importa linha
End If
Next Row
dgvCPF.DataSource = DtAux
End If
Aviso.Fechar()