vergel aranas

vergel aranas

  • NA
  • 70
  • 17k

Hi Sir, i just want to ask and need some help on how can i display data from mysql to c# listview

Jul 1 2012 12:05 PM
Hi Sir, i just want to ask and need some help on how can i display data from mysql to c# listview. Here is my code but not working.

            clientlistview.Items.Clear();
            string sqlselect = "SELECT clientId, clientFName, clientMName, clientLName from clientreg";
            MySqlConnection connect = new MySqlConnection(conn);
            MySqlCommand cm = new MySqlCommand(sqlselect, connect);
            DataTable tbl = new DataTable();
            MySqlDataReader read = cm.ExecuteReader();
            foreach (DataRow row in tbl.Rows)
            {
                ListViewItem list = new ListViewItem(row[0].ToString());
                list.SubItems.Add(row[1].ToString());
                list.SubItems.Add(row[2].ToString());
                list.SubItems.Add(row[3].ToString());
                clientlistview.Items.Add(list);
            }
Thanks in advance Sir!

Answers (3)