VB .Net 2008 - MS Access 2007 (accdb) Connection

This is Tutorial Visual Basic .Net 2008 : How to connect Database MS Access 2007 (.accdb), this tutorial can use for DB access 2007 or DB access 2010 or DB access 2013. You can see the extension for Database (.accdb)
  • Step 1: Create New Project use VB 2008
  • Step 2 :Create database and table in MS Access 2003
  • Step 3 : Design form in VB .Net 2008
#Step 1 :
Make sure you already install VB 2008 in your computer
Click Start in your windows
All Programs

Choose Microsoft Visual Studio 2008
Click File - New - Project

Below after click New Project:
Click OK

After that, please follow STEP 2
#Step 2 :
Create Database use MS Access 2003
Database name : db.mdb
Table name : TBL_PRODUCT
design table like below picture :

fill sample product
 Save db.mdb at : D:\MyApp\MyApp\MyApp\bin\Debug

#Step 2 :
Open Visual Basic .Net 2008
 File - New - Project
Select Windows Forms Application
Name : MyApp
Select your location
Click OK
Design form1 like below picture
Just add "Datagridview1" in Form1

Fill below code at Form1

Imports System.Data.OleDb
Public Class Form1
    Dim Conn As OleDbConnection
    Dim da As OleDbDataAdapter
    Dim ds As DataSet
    Dim DBLocation As String
    Sub Koneksi()
        DBLocation = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=DB.accdb"
        Conn = New OleDbConnection(DBLocation)
        If Conn.State = ConnectionState.Closed Then Conn.Open()
    End Sub
    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Koneksi()
        da = New OleDbDataAdapter("Select * from TBL_PRODUCT", Conn)
        ds = New DataSet
        ds.Clear()
        da.Fill(ds, "TBL_PRODUCT")
        DataGridView1.DataSource = (ds.Tables("TBL_PRODUCT"))
    End Sub
End Class
Here the result :
Please click here to download project / source code above

Subscribe to receive free email updates:

0 Response to "VB .Net 2008 - MS Access 2007 (accdb) Connection"

Post a Comment