help with populating a listview control with data from ana access database

  • 14 years ago

    First i must saying i am working on a project in vb.net with an access database , the problem i am having is that i have a listview control on my form and i would like to populate the listview with data from my access database table , i have never used a listview before and i don't know  how to bind the data from the database table to the listview ..
    can someone please help me .. for the record i am a newbie
    thanks in advance

  • 14 years ago

    The simple answer is that you don't.  The ListView doesn't support data-binding like the DataGrid and DataGridView do.  You have to manually create each item and subitem and add them to the ListView.  There is also no link back to the original data so it's up to you to make those updates.

    You do have the option of using the ExtendedListView in the Windows Forms Components library, which is almost exactly like a standard ListView and does support data binding.

    Windows Forms Components





  • 14 years ago

    well i didn't know that , thanks for your help , i guess i will have to try and do what u say and see if it will work

     

  • 14 years ago

    you can, but you should use classical access to your database

    dim con as new oledb.connection
    con.connectionstring = "...blablabla.mdb"
    dim cmd as new oledb.oledbcommand
    cmd.connection = con /not sure bout that
    cmd.type = command.text
    cmd.command = "select surname from customers where 1"
    dim myread as new oledb.dataReader
    myread = cmd.executereader

    while myread.read
     listview.items.add(myread.getvalue(0))
    end while












    I am not perfectly sure if it is somehow correct, but at least it is some direction...





  • 14 years ago

    cool , will try

    thanks

     

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“I have always wished for my computer to be as easy to use as my telephone; my wish has come true because I can no longer figure out how to use my telephone” - Bjarne Stroustrup