BUSCAR PARA DATAGRID

DANIELFELIX91 23/11/2011 09:55:52
#389815
Bom Dia,

Tenho um DataGrid em um formulario e 2 textbox, 1 para codigo e outro para celular, gostaria que quando Eu digitar no celular tambem buscasse no datagrid os dados... pois só consigo fazer com que busque pelo codigo... segue o meu codigo.


NO MODULE:

Sub carregagrid()
[ô]exibe informação da tabela no grid
tabela = New ADODB.Recordset
tabela.Open([Ô]select * from movel order by codigo, celular[Ô], conecta)
da = New OleDbDataAdapter
ds = New DataSet
da.Fill(ds, tabela, [Ô]Movel[Ô])
filtro.grid.DataSource = ds.Tables([Ô]Movel[Ô])
filtro.grid.Refresh()
End Sub

NO FORM DO DATA GRID:

Public Class filtro

Private Sub filtro_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
carregagrid()
End Sub

Private Sub txtcodbus_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtcodbus.TextChanged
ds = New DataSet
tabela = New ADODB.Recordset
tabela.Open([Ô]SELECT * FROM movel WHERE codigo LIKE [ô][Ô] & txtcodbus.Text & [Ô]%[ô] [Ô], conecta, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockBatchOptimistic)
da.Fill(ds, tabela, [Ô]ITEM[Ô])
grid.DataSource = ds.Tables(0)
End Sub
Sub linhaselecionadaDOGrid()
consulta.Show()
With consulta
.txtcod.Text = grid.Rows(grid.SelectedCells(0).RowIndex).Cells(0).Value.ToString()
.mskcel.Text = grid.Rows(grid.SelectedCells(0).RowIndex).Cells(1).Value.ToString()
End With
Me.Hide()
End Sub

Private Sub grid_CellContentClick(ByVal sender As System.Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles grid.CellContentClick
linhaselecionadaDOGrid()
End Sub

Private Sub mskcel_MaskInputRejected(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MaskInputRejectedEventArgs) Handles mskcel.MaskInputRejected
ds = New DataSet
tabela = New ADODB.Recordset
tabela.Open([Ô]SELECT * FROM movel WHERE celular LIKE [ô][Ô] & mskcel.Text & [Ô]%[ô] [Ô], conecta, ADODB.CursorTypeEnum.adOpenStatic, ADODB.LockTypeEnum.adLockBatchOptimistic)
da.Fill(ds, tabela, [Ô]ITEM[Ô])
grid.DataSource = ds.Tables(0)
End Sub
End Class

Obrigado.
ROBFERREIRAA 16/08/2012 16:53:13
#408043
ola seu select esta estrando tenta fazer assim
select codigo, celular FROM movel order by codigo, celular
ate mais
Tópico encerrado , respostas não são mais permitidas