Pages

Total Pageviews

Add This

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

No comments:

Post a Comment