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()
            With connection
                If .State = ConnectionState.Open Then .Close()
                .ConnectionString = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=Contacts.mdb"
            End With
        Catch ex As Exception
            MessageBox.Show("Not connected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
End Sub

No comments:

Post a Comment