Hello
I have a program for msaccess 2007 and VS 2010, every thing working correctly except saving the data to the database. by the way its reading correctly from the dbase
Here is the code:
Add new record:
private void button4_Click(object sender, EventArgs e)
{
f1.Text = "";
f2.Text = "";
newCustomersRow = pharmaDataSet.Tables["drugType"].NewRow();
newCustomersRow["DName"] = f1.Text.ToString();
newCustomersRow["Description"] = f2.Text.ToString();
pharmaDataSet.Tables["drugType"].Rows.Add(newCustomersRow);
drugTypeBindingSource.MoveLast();
DataGridViewDataErrorContexts cntxt = new DataGridViewDataErrorContexts();
dg.CommitEdit(cntxt);
drugTypeBindingSource.MoveLast();
f1.Text = "";
f2.Text = "";
}
Delete record:
private void button3_Click(object sender, EventArgs e)
{
try
{
drugTypeBindingSource.RemoveCurrent();
}
catch (Exception)
{
}
}
Save to DBase
private void button2_Click(object sender, EventArgs e)
{
this.Validate();
this.drugTypeBindingSource.EndEdit();
tableAdapterManager.UpdateAll(pharmaDataSet);
/*
* drugTypeBindingSource.DataSource = pharmaDataSet.drugType;
dg.DataSource = drugTypeBindingSource;
drugTypeTableAdapter.Update(pharmaDataSet.drugType);
*/
drugTypeTableAdapter.Update(pharmaDataSet.drugType);
pharmaDataSet.drugType.AcceptChanges();
ActiveForm.Close();
// tableAdapterManager.UpdateAll(pharmaDataSet);
}
private void ff_TextChanged(object sender, EventArgs e)
{
try
{
// customerCreditBindingSource BindingSource myBindingSource;
//dg.DataSource = drugTypeBindingSource;
//drugTypeBindingSource.DataSource = pharmaDataSet;
//drugTypeBindingSource.DataMember = pharmaDataSet.Tables[2].TableName;
drugTypeBindingSource.Filter = "DName Like '" + ff.Text + "%'";
// button2.Visible = false;
// button4.Visible = false;
}
catch (Exception) { }
}