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

3:36:00 PM
This is tutorial  How to connect DB Access 2007 (accdb) using Visual Basic 2005. it's very easy to learning Visual Studio 2005 with us..
Please follow below steps :
  • Step 1: Create New Project use VB 2005
  • Step 2 :Create database and table in MS Access 2007
  • Step 3 : Design form in VB .Net 2005
#Step 1 :
Make sure you already install VB 2005 in your computer
Click Start in your windows
All Programs
Choose Microsoft Visual Studio 2005
Click File - New - Project
Below after click New Project:
Click OK
After that, please follow STEP 2
#Step 2 :
Create Database use MS Access 2007 (accdb)
Database name : db.mdb
Table name : TBL_PRODUCT
design table like below picture :
fill sample produc

Save db.mdb at : D:\MyApp\MyApp\MyApp\bin\Debug

#Step 3 :
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 DBConn()
       
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
        DBConn()
        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

Artikel Terkait

Next Article
« Prev Post
Previous Article
Next Post »
Penulisan markup di komentar
  • Untuk menulis huruf bold silahkan gunakan <strong></strong> atau <b></b>.
  • Untuk menulis huruf italic silahkan gunakan <em></em> atau <i></i>.
  • Untuk menulis huruf underline silahkan gunakan <u></u>.
  • Untuk menulis huruf strikethrought silahkan gunakan <strike></strike>.
  • Untuk menulis kode HTML silahkan gunakan <code></code> atau <pre></pre> atau <pre><code></code></pre>, dan silahkan parse dulu kodenya pada kotak parser di bawah ini.
Konversi Code
Disqus
Silahkan Berkomentar Dengan