Pages

Total Pageviews

Add This

Showing posts with label Microsoft Access 2003. Show all posts
Showing posts with label Microsoft Access 2003. Show all posts

Monday, July 25, 2011

Populate Listview

If you use Microsoft Access 2003 as a database, Microsoft.ACE.OLEDB.12.0 as a Provider and Listview as a Form control, to populate the Listview after the connecting then 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

Saturday, July 23, 2011

Populate Listview

If you use Microsoft Access 2003 as a database, Microsoft.ACE.OLEDB.12.0 as a Provider and Listview as a Form control, to populate the Listview after the connecting then 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

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

Populate Listview

If you use Microsoft Access 2003 as a database, Microsoft.ACE.OLEDB.12.0 as a Provider and Listview as a Form control, to populate the Listview after the connecting then 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