Get table data into a listview object

Jul 16 2008 6:23 AM
Hi

i want to get data from my access table and put in in a listview in my program.
I'm newbie in C#. Can anyone help me with this?
I have a metod called oppnaAdressBok.

here is the code:

 void oppnaAdressBok(object sender, EventArgs ex)
    {
        string connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=\\..\\persondata.mdb";
        OleDbConnection myConnection = new OleDbConnection(connectionString);

        string query = "select * form data";

        OleDbDataAdapter myAdapter = new OleDbDataAdapter(query, myConnection);
        DataSet personData = new DataSet();
        myAdapter.Fill(personData);
        ListViewItem nyKontakt = new ListViewItem();

        //Repetera för varje tabell
        foreach (DataTable table in personData.Tables)
        {
            //repetera för varje row i tabellen
           
            foreach (DataRow row in table.Rows)
            {
               
              // code here.
             
            }
        }
    }

Answers (5)