:(
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 :(
Ankur JainPosted Aug 7, 2014, 11:40 PM
Try like this...
Note no more "+=" and you add the ListViewItems one by one.
if it helps, please mark it as answer
Sanjay KumarPosted Aug 8, 2014, 1:17 AM
http://sqlneed.blogspot.in/2014/04/How-to-load-data-into-listview-from-database.html
http://www.c-sharpcorner.com/UploadFile/mgold/ListViewInCSharp11172005021741AM/ListViewInCSharp.aspx