04/07/2011, 12:43
|
| | Fecha de Ingreso: julio-2011
Mensajes: 7
Antigüedad: 13 años, 4 meses Puntos: 0 | |
filtrar datagridview Buenas tardes
estoy tratando de filtrar un datagridview mediante el ingreso de letras en un textbox pero no logro que funcione.
Soy nuevo en este foro y a demas estoyaprendiendo .net
les paso el codigo y les pido una mano. gracias.
Imports System.Data
Imports System.Data.OleDb
Public Partial Class MainForm
Public Sub New()
' The Me.InitializeComponent call is required for Windows Forms designer support.
Me.InitializeComponent()
'
' TODO : Add constructor code after InitializeComponents
'
End Sub
Sub Button1Click(sender As Object, e As EventArgs)
Dim cnn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=D:\Documents and Settings\teastp\Desktop\iniciando en net\parte 12\Northwind.mdb; User Id=admin;Password=;")
Dim da As New OleDbDataAdapter("SELECT * FROM Products", cnn)
Dim ds As New DataSet
da.Fill(ds)
DataGridview1.DataSource = ds.Tables(0)
End Sub
Sub TextBox1TextChanged(sender As Object, e As EventArgs)
Dim cnn As OleDbConnection=New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=D:\Documents and Settings\taluc\Desktop\base de datos\Northwind.mdb; User Id=admin;Password=;")
dim sql as String="SELECT * FROM PRODUCTS WHERE PRODUCTNAME like '%" + TextBox1.Text.Trim
Dim da As OleDbDataAdapter= New OleDbDataAdapter(sql, cnn)
dim dt as DataSet=New DataSet(0)
da.Fill(dt)
Me.DataGridView1.DataSource = dt
me.Refresh
End Sub
End Class |