Concept Of AcceptChanges() and RejectChanges()
ExpressionDataSet ds;
ExpressionDataSetTableAdapters.expressionTableAdapter sta;
private void AcpBtn_Click(object sender, EventArgs e)
{
try
{
ds = new ExpressionDataSet();
sta = new ExpressionDataSetTableAdapters.expressionTableAdapter();
sta.Fill(ds.expression);
DataRow dr = ds.expression.NewRow();
dr ["StudentID"] = textBox1.Text;
dr["Name"] = textBox2.Text;
dr["English"] = textBox3.Text;
dr["Chemistry"] = textBox4.Text;
dr["Math"] = textBox5.Text;
ds.expression.Rows.Add(dr);
sta.Adapter.Update(ds.expression);
ds.expression.AcceptChanges();
MessageBox.Show("Stored");
}
catch(Exception ex)
{
ds.RejectChanges();
}
}
ExpressionDataSetTableAdapters.expressionTableAdapter sta;
private void AcpBtn_Click(object sender, EventArgs e)
{
try
{
ds = new ExpressionDataSet();
sta = new ExpressionDataSetTableAdapters.expressionTableAdapter();
sta.Fill(ds.expression);
DataRow dr = ds.expression.NewRow();
dr ["StudentID"] = textBox1.Text;
dr["Name"] = textBox2.Text;
dr["English"] = textBox3.Text;
dr["Chemistry"] = textBox4.Text;
dr["Math"] = textBox5.Text;
ds.expression.Rows.Add(dr);
sta.Adapter.Update(ds.expression);
ds.expression.AcceptChanges();
MessageBox.Show("Stored");
}
catch(Exception ex)
{
ds.RejectChanges();
}
}
No comments:
Post a Comment