private void button2_Click(object sender, EventArgs e) { try { con = new MySqlConnection(constring); cmdabsent = new MySqlCommand("SELECT sem,course,division,rollno,name FROM attendance WHERE course='" + coursecombo + "' AND sem='" + semcombo + "' AND division='" + divcombo + "'", con); MySqlDataAdapter dafillabsent = new MySqlDataAdapter(cmdabsent); MySqlCommandBuilder cmdbul = new MySqlCommandBuilder(dafillabsent); DataSet dsfillabsent = new DataSet(); dsfillabsent.Clear(); dafillabsent.Fill(dsfillabsent, "AllAbsent"); dsfillabsent.Tables["AllAbsent"].Columns.Add(new DataColumn("date")); dsfillabsent.Tables["AllAbsent"].Columns.Add(new DataColumn("status")); CheckedListBox.CheckedItemCollection o = checkedListBox1.CheckedItems; for(int i=0;i<=Convert.ToInt32(total)-1;i++) { dsfillabsent.Tables["AllAbsent"].Rows[i]["date"] = Convert.ToDateTime(dateTimePicker1.Value); if (o.Contains(i)) { dsfillabsent.Tables["AllAbsent"].Rows[i]["status"] = "A"; } else { dsfillabsent.Tables["AllAbsent"].Rows[i]["status"] = "P"; } } //dafillabsent.Update(dsfillabsent.Tables["AllAbsent"]); dataGridView1.DataSource = dsfillabsent.Tables["AllAbsent"]; } catch (Exception ex) { MessageBox.Show("ERROR: " + ex, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
if (checkedListBox1.CheckedIndices.Contains(i)) { dsfillabsent.Tables["AllAbsent"].Rows[i]["status"] = "A"; } else { dsfillabsent.Tables["AllAbsent"].Rows[i]["status"] = "P"; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)