Imports System.Data.OleDb
Public Class Form1
Public Conn As New OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Application.StartupPath & "\MyData.MDB")
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.CenterToScreen()
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
If Conn.State = ConnectionState.Open Then Conn.Close()
Conn.Open()
DataGridView1.ClearSelection()
Dim dt As New DataTable
Dim ds As New DataSet
ds.Tables.Add(dt)
Dim da As New OleDbDataAdapter
da = New OleDbDataAdapter("Select * From Table1 Where dName Like '%" & TextBox1.Text & "%'", Conn)
da.Fill(dt)
DataGridView1.DataSource = dt
Conn.Close()
End Sub
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
If Conn.State = ConnectionState.Open Then Conn.Close()
Conn.Open()
DataGridView1.ClearSelection()
Dim dt As New DataTable
Dim ds As New DataSet
ds.Tables.Add(dt)
Dim da As New OleDbDataAdapter
da = New OleDbDataAdapter("Select * From Table1 Where SCB >= 0 AND KTB >= 0 AND TMB >= 0 AND UOB >= 0", Conn)
da.Fill(dt)
DataGridView1.DataSource = dt
Conn.Close()
End Sub
End Class