Pages

Total Pageviews

Add This

Friday, May 13, 2011

Conncet to Microsoft Access Database 2003

To easily connect Microsoft Access 2003 database to Visual Basic 2010 first you have to enter this line of code:

Imports System.Data.OleDb

After you can use the function bellow:

Public Sub Connect_database()
        Try
            With connection
                If .State = ConnectionState.Open Then .Close()
                .ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Contacts.mdb"
                .Open()
            End With
        Catch ex As Exception
            MessageBox.Show("Not connected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
            Application.Exit()
        End Try
    End Sub

1 comment:

  1. To be honest I have never seen a better tutorials. Very well structured and descriptive. Keep up the good work. I am myself an experienced programmer but yet look at your work.

    ReplyDelete