I have roughly 100,000 records in a datagridview that I am selecting records using a user input criteria in another search form. But its taking way to long to loop through each record and select them. Is there a faster way of doing this? Here is my code:
Here is How I am importing the data:Code:For Each strLine As String In TextBox2.Text.Split(vbNewLine) Dim SearchFor As String = strLine.ToString If SearchFor = vbLf & "AND" Or SearchFor = vbLf & "OR" Then Else If EquationVariable = "=" Then ItemToFind = SearchFor.Substring(SearchFor.LastIndexOf("=") + 1).TrimStart For Each R0w In DataGridView1.Rows NewCount = R0w.index ProgressBar1.Value = NewCount If DataGridView1(0, R0w.index).Value = True Then Else ColumnName = SearchFor.Substring(0, SearchFor.IndexOf("=") - 1) ColumnNameSearch = ColumnName DataGridView1.CurrentCell = DataGridView1.Item(ColumnName, R0w.index) If Not IsDBNull(DataGridView1.CurrentCell.Value) AndAlso DataGridView1.CurrentCell.Value = ItemToFind Then DataGridView1.CurrentRow.DefaultCellStyle.ForeColor = Color.Red DataGridView1(0, R0w.index).Value = True Else End If End If Next Else MsgBox(ListBox1.SelectedItem.ToString & " Doest not = " & ItemToFind) End If End If Next
Code:MyConnection = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\Work\Import.xlsx;Extended Properties=Excel 12.0;") MyCommand = New System.Data.OleDb.OleDbDataAdapter("select * from [Sheet1$]", MyConnection) MyCommand.TableMappings.Add("Table", "Net-informations.com") DtSet = New System.Data.DataSet MyCommand.Fill(DtSet) tab = DtSet.Tables(0) DataGridView1.DataSource = tab MyConnection.Close()




Reply With Quote
