verileri göstereceğiz. (Şekil 1)
Formunuza 1 adet TextBox ve DataGridView Nesnesi ekleyin.
Nortwind.mdb veritabanındaki Customers tablosundan bilgileri çekeceğiz.
Şekil 3
Public Class Form1
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Dim baglan As System.Data.OleDb.OleDbConnection = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Northwind.mdb")
Dim adp As New OleDb.OleDbDataAdapter()
Dim str As String
str = "Select * From Customers Where CustomerID like '%" & TextBox1.Text & "%'"
adp.SelectCommand = New OleDb.OleDbCommand(str, baglan)
Dim CB As OleDb.OleDbCommandBuilder = New OleDb.OleDbCommandBuilder(adp)
Dim cmd As New Data.OleDb.OleDbCommand(str, baglan)
If (baglan.State = ConnectionState.Closed) Then
baglan.Open()
End If
Dim ds As New DataSet()
adp.Fill(ds)
DataGridView1.DataSource = ds.Tables(0)
baglan.Close()
End Sub
End Class
Bir sonraki makalede görüşmek üzere. Bahadır ŞAHİN
Public Class Form1
Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
Dim baglan As System.Data.OleDb.OleDbConnection = New System.Data.OleDb.OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=Northwind.mdb")
Dim adp As New OleDb.OleDbDataAdapter()
Dim str As String
str = "Select * From Customers Where CustomerID like '%" & TextBox1.Text & "%'"
adp.SelectCommand = New OleDb.OleDbCommand(str, baglan)
Dim CB As OleDb.OleDbCommandBuilder = New OleDb.OleDbCommandBuilder(adp)
Dim cmd As New Data.OleDb.OleDbCommand(str, baglan)
If (baglan.State = ConnectionState.Closed) Then
baglan.Open()
End If
Dim ds As New DataSet()
adp.Fill(ds)
DataGridView1.DataSource = ds.Tables(0)
baglan.Close()
End Sub
End Class
Bir sonraki makalede görüşmek üzere. Bahadır ŞAHİN
0 comments:
Yorum Gönder