Aplikasi Sederhana VB 2008 menggunakan database microsoft acces 2007
contoh aplikasi tentang penjualan kosmetik,yaitu langkah pertama membuat database di microsoft access 2007 ,sebagai berikut:1.Table Penjualan
3.Data Pelanggan
5.Query
-> untuk form data barang
-> untuk coding di view
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.OleDb
Partial Public Class de
Inherits System.Web.UI.Page
Dim koneksi As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\heni\Documents\transaksi.accdb"
Dim objekoneksi As New OleDb.OleDbConnection(koneksi)
Protected Sub txtkode_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtkode.TextChanged
objekoneksi.Open()
Dim sqlTambah = "Insert Into data_barang values ('" & txtkode.Text & "','" & txtnama.Text & "','" & txtharga.Text & "','" & txtvendor.Text & "' )"
Dim ocmd = New OleDbCommand(sqlTambah, objekoneksi)
ocmd.ExecuteNonQuery()
objekoneksi.Close()
End Sub
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Response.Redirect("viewbarang.aspx")
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
End Sub
End Class
-> kemudian menambah form dengan klik projectnya kemudian klik kanan lalu klik new item maka akan tampil form baru dan untuk design form baru menggunakan nama data pelanggan ,contohnya sebagai berikut :
-> untuk codingnya sebagai berikut :
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.OleDb
Partial Class datapelanggan
Inherits System.Web.UI.Page
Dim koneksi As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Users\heni\Documents\transaksi.accdb"
Dim objekoneksi As New OleDb.OleDbConnection(koneksi)
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub txtkode_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtkode.TextChanged
objekoneksi.Open()
Dim sqlTambah = "Insert Into data_pelanggan values ('" & txtkode.Text & "','" & txtnama.Text & "','" & txttlp.Text & "','" & txtemail.Text & "' )"
Dim ocmd = New OleDbCommand(sqlTambah, objekoneksi)
ocmd.ExecuteNonQuery()
objekoneksi.Close()
End Sub
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Response.Redirect("viewpelanggan.aspx")
End Sub
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button2.Click
End Sub
End Class
-> klik projectnya lagi kemudian klik kanan lalu klik new item dan design form menggunakan nama data vendor,contohnya sebagai berikut :
-> berikut codingnya
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.OleDb
Partial Class Default2
Inherits System.Web.UI.Page
Dim koneksi As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\uts pa agus\transaksi.accdb"
Dim objekoneksi As New OleDb.OleDbConnection(koneksi)
Protected Sub txtkode_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtkode.TextChanged
objekoneksi.Open()
Dim sqlTambah = "Insert Into data_vendor values ('" & txtkode.Text & "','" & txtnama.Text & "','" & txttlp.Text & "','" & txtemail.Text & "' )"
Dim ocmd = New OleDbCommand(sqlTambah, objekoneksi)
ocmd.ExecuteNonQuery()
objekoneksi.Close()
End Sub
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Response.Redirect("viewvendor.aspx")
End Sub
End Class
-> kemudian buat form baru lagi dengan nama rekaptransaksi, contoh sebagai berikut :
-> untuk codingnya sebagai berikut
Partial Class rekaptransaksi
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
End Sub
End Class
->kemudian membuat form lagi dengan nama transaksi
-> Berikut Codingnya
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.OleDb
Partial Class Default2
Inherits System.Web.UI.Page
Dim koneksi As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\uts pa agus\transaksi.accdb"
Dim objekoneksi As New OleDb.OleDbConnection(koneksi)
Protected Sub txtid_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtid.TextChanged
objekoneksi.Open()
Dim sqlTambah = "Insert Into tabel_jual values ('" & txtid.Text & "','" & txtkode.Text & "','" & txtqty.Text & "' )"
Dim ocmd = New OleDbCommand(sqlTambah, objekoneksi)
ocmd.ExecuteNonQuery()
objekoneksi.Close()
End Sub
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
Response.Redirect("rekaptransaksi.aspx")
End Sub
End Class
-> Kemudian membuat form baru dengan nama viewbarang, berikut contohnya
-> berikut codingnya
Partial Class viewbarang
Inherits System.Web.UI.Page
Protected Sub GridView1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles GridView1.SelectedIndexChanged
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
End Sub
Protected Sub Button2_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button2.Click
End Sub
End Class
-> Kemudian buat form baru lagi dengan nama viewpelanggan
-> Selanjutnya membuat form baru dengan nama viewvendor
Cukup sekian aplikasi sederhananya & semoga bermanfaat