Monday, October 19, 2015

Imports System.Data
Imports System.Data.OleDb

Public Class Form1
    Dim koneksi As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=D:\Bagas\LAB VB 2\DataPemesananTiket.accdb"
    Dim ob_koneksi As New OleDb.OleDbConnection(koneksi)
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'DataPemesananTiketDataSet1.TablePemesanan' table. You can move, or remove it, as needed.
        Me.TablePemesananTableAdapter.Fill(Me.DataPemesananTiketDataSet1.TablePemesanan)

    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        ob_koneksi.Open()
        Dim tambah As String = "Insert into TablePemesanan values ('" & TextBox1.Text & "' , '" & TextBox2.Text & " ' , ' " & TextBox3.Text & " ' , ' " & ComboBox1.Text & " ' , ' " & ComboBox2.Text & " ' , ' " & TextBox4.Text & " ' )"
        Dim oCmd = New OleDbCommand(tambah, ob_koneksi)
        oCmd.ExecuteNonQuery()
        MsgBox("Sukses")
        ob_koneksi.Close()
    End Sub

    Private Sub TextBox4_TextChanged(sender As Object, e As EventArgs) Handles TextBox4.TextChanged

    End Sub

    Private Sub ComboBox2_SelectedIndexChanged(sender As Object, e As EventArgs) Handles ComboBox2.SelectedIndexChanged
        If ComboBox2.Text = "Eksekutif" Then
            TextBox4.Text = 350000
        ElseIf ComboBox2.Text = "Bisnis" Then
            TextBox4.Text = 250000
        ElseIf ComboBox2.Text = "Ekonomi" Then
            TextBox4.Text = 100000
        End If
    End Sub
End Class

Cara memasuki data ke acces dengan vb
1.Buka project di vb 2013.

2. Lalu debug program nya dan lalu masukan data nya dan klik ok

3.Lalu buka file acces anda dan data sudah ada