Please following below steps :
#1. Create Database and Table in Access 2007 ( accdb )
Create Database :DBTM.accdb
Create Table : TBL_SUPPLIER
Please see below picture for Design TBL_SUPPLIER
#2. Open and Design From in Visual Basic .Net
Open Visual Basic .Net in Your Computer
Create Form1 like below picture
Save datatabe to project Visual Basic .Net folder : Debug
and then place below code to Form1
Imports System.Data.OleDb
Public Class Form1
Dim Conn As OleDbConnection
Dim da As OleDbDataAdapter
Dim ds As DataSet
Dim MyDB As String
Sub ConnectDB()
MyDB = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=DBTM.accdb"
Conn = New OleDbConnection(MyDB)
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
ConnectDB()
da = New OleDbDataAdapter("Select * from TBL_SUPPLIER", Conn)
ds = New DataSet
ds.Clear()
da.Fill(ds, "TBL_SUPPLIER")
DataGridView1.DataSource = (ds.Tables("TBL_SUPPLIER"))
End Sub
End Class
Run your project and below for the result :
Click Here to download source code above
0 Response to "VB .Net - How to connect Access 2007 (.accdb) Database"