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

2 comments:

  1. Exactly what I needed. Thanks for the nice codes you have.

    ReplyDelete
  2. It was a problem for me to populate Listview with data.
    Thanks

    ReplyDelete

There was an error in this gadget