Contoh Binding Navigator, Binding Source dan Data Grid View Pada Microsoft Visual Basic .Net/VB 2005/VB 2008

Tuesday, November 8, 2011

1. Buat Projek baru
2. Tambahkan 1 buah Form
3. Tambahkan 1 Binding Navigator, Binding Source dan Data Gridview Ke Form
4. Copy Code Berikut Ini

Imports System.Data
Imports System.Data.OleDb 'OLDB = Database Microsoft Accses If SQL Server Use
"SqlClient"
Public Class
Form14 'Form14 name Form
Private Sub Form14_Load(ByVal
sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
excute()
End Sub
Private Sub excute()
Dim sql
As String
Dim
sqlCommand As New
OleDbCommand
Dim
sqlAdap As OleDbDataAdapter
Dim
dtaTbl As New
DataTable
sql = "select
* from table1 "
sqlCommand = New
OleDbCommand(sql, con)
sqlAdap = New
OleDbDataAdapter(sqlCommand)
sqlAdap.Fill(dtaTbl)
BindingSource1.DataSource = dtaTbl
DataGridView1.DataSource =
BindingSource1
BindingNavigator1.BindingSource =
BindingSource1
End Sub
'Remarks OleDb =
Database Microsoft Accses If SQL Server Use "SQL"
End Class
5. Apabila sudah selesai run projek, maka akan tampil seperti berikut
Note : Contoh ini harus sudah mengetahui tentang aplikasi database terlebih dahulu jika belum tau ada di posting sebelumnya

1 comments:

surya suryawan said...

aneh banget bentuknya bro..