Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Imports System.Data.OleDb
- Public Class Form1
- Dim Conn As OleDbConnection
- Dim cmd As OleDbCommand
- Dim da As OleDbDataAdapter
- Dim ds As New DataSet
- Dim dr As OleDbDataReader
- Dim LokasiDB As String
- Sub Koneksi()
- LokasiDB = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=dbjnm.accdb"
- Conn = New OleDbConnection(LokasiDB)
- If Conn.State = ConnectionState.Closed Then Conn.Open()
- End Sub
- Sub isiCombo()
- cmd = New OleDbCommand("Select namaBarang from Barang", Conn)
- dr = cmd.ExecuteReader
- Do While dr.Read
- ComboBox1.Items.Add(dr.Item(0))
- Loop
- End Sub
- Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
- ComboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDown
- ComboBox1.AutoCompleteMode = AutoCompleteMode.SuggestAppend
- ComboBox1.AutoCompleteSource = AutoCompleteSource.ListItems
- Koneksi()
- da = New OleDbDataAdapter("Select * from barang", Conn)
- ds = New DataSet
- ds.Clear()
- da.Fill(ds, "Barang")
- DataGridView1.DataSource = (ds.Tables("Barang"))
- isiCombo()
- End Sub
- Private Sub ComboBox1_GotFocus(sender As Object, e As EventArgs) Handles ComboBox1.GotFocus
- ComboBox1.DroppedDown = True
- End Sub
- End Class
Advertisement
Add Comment
Please, Sign In to add comment