3
Answers

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

vergel aranas

vergel aranas

12y
1.3k
1
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)