Que tal amigos foreros, weno mi consula es esta, si tengo el siguiente codigo que funciona que hace la busqueda de datos en un DataGrid, y funciona si busco una sola palabra, PEPITO, mi problema es, que no se por que, cuando hago la busqueda de PEPITO%PEREZ, alli me da un error diciendome:
Cita: Error en el operador like: el modelo de la cadena 'PEREZ%PEPITO%' no es valido
y se para en esta parte:
Código:
.DefaultView.RowFilter = "acestnomb like '" & TextBox1.Text & "%'"
este es el codigo que utilizo:
Código:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim ds As DataSet
Dim NOMBRE_TABLA As String = "acest"
ds = emp.consulta("SELECT UNIQUE acestnreg,acestnomb,acestcarr,acestplan,acpertlfd,acpercelu,accondesc " & _
"FROM acest,acper,accon " & _
"WHERE acestnreg = acpernreg " & _
" AND accongrup = 18 " & _
" AND acconsubg = acestband ")
DataGrid1.DataSource = ds.Tables("acest")
Const MESSAGEBOX_CAPTION As String = "Buscar"
' Sanity check to make sure there's data before attempting to
' filter
Debug.Assert(Not ds.Tables(NOMBRE_TABLA) Is Nothing, _
"No product data loaded in ProductData.Tables(NOMBRE_TABLA)")
With ds.Tables(NOMBRE_TABLA)
' Filter the view so that only product names starting with a
' specified string are available.
.DefaultView.RowFilter = "acestnomb like '" & TextBox1.Text & "%'"
' Are there any matching products?
If .DefaultView.Count = 0 Then
MessageBox.Show("No se encontro fila alguna.", _
MESSAGEBOX_CAPTION, _
MessageBoxButtons.OK, _
MessageBoxIcon.Question)
End If
' By binding the grid to the DataView, the grid will now display
' only the matching rows.
DataGrid1.DataSource = .DefaultView
End With
End Sub