0
I load the data from a database into a Bindingsource and use it to make searches.
The same is tied with a datagridview
, whose return me the data sought, at the moment I am using LIKE to do these searches, but it is not pleasing me see the example below:
ValorProcurado = Par*3/4*3 >>>>> aqui estou tentando procurar um parafuso 3/4x3 na minha tabela
Dim Tabela As New BindingSource
Dim Valores() As String = Split(ValorProcurado, "*")
Dim Valor As String = ""
Dim ValorFiltro As String = ""
For Each Valor In Valores
If ValorFiltro = "" Then
ValorFiltro = "'%" & Valor & "%'"
Else
ValorFiltro = ValorFiltro & " AND " & ColunaFiltro & " LIKE '%" & Valor & "%'"
End If
Next
Tabela.Filter = "Descricao LIKE " & ValorFiltro
The way I am doing I can search the values, but it is not searched in the sequence I put, I wanted in this example above that the datagridview returns me items that start with "pair" and then following the sequence had "3/4" and then had "3".
This is VB?.....
– Sam
yes sorry....
– welinton vito
That part here
ValorProcurado = Par*3/4*3
shouldn’t be a string, like:ValorProcurado = "Par*3/4*3"
– Sam
Yes, it’s already that way, the code is working, but as I explained I wanted the search to be sequential and not the way it is
– welinton vito
The clause WHERE should not have OR instead of AND? Because that way you’re limiting the spectrum of results too much.
– João Martins