Imports System.Data.OleDb
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Dim conn As New OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=E:\ddd.accdb")
If conn.State = ConnectionState.Closed Then
conn.Open()
End If
Dim cmd1 As New OleDbCommand("select id,firstname,lastname,sum from table1 where firstname like '%" + TextBox1.Text + "%'", conn)
Dim da As New OleDbDataAdapter
Dim dt As New DataTable
da.SelectCommand = cmd1
dt.Clear()
da.Fill(dt)
DataGridView1.DataSource = dt
conn.Close()
End Sub
End Class
No comments:
Post a Comment