Saudie Esmail

Saudie Esmail

  • NA
  • 13
  • 7.2k

Listview with database.

Aug 7 2014 9:57 PM
:( 
how can save the items in listview?? I tried this
 
private void btnSave_Click(object sender, EventArgs e)
{
try
{
con.Close();
con.Open();
foreach (ListViewItem Itm in listView1.Items)
cmd = new MySqlCommand("INSERT into sched_tbl (Day,Coursecode,Time,room)" + " VALUE('" + Itm.SubItems[0].Text + "','" + Itm.SubItems[1].Text + "','" + Itm.SubItems[2].Text + "','" + Itm.SubItems[3].Text + "')", con);
dt = cmd.ExecuteReader();
con.Close();
MessageBox.Show("good");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
con.Close();
}
 
 
It work but my problems is only the first item is saved in my database..
I need help.. thanks :( 

Answers (2)