我的C#代码将新数据保存到临时数据集,但不保存到永久数据库。以下是我的代码:
公共部分类AddProduct:表单
{
private Database1DataSet db1ds = new Database1DataSet();
public AddProduct()
{
InitializeComponent();
}
private void tblProductBindingNavigatorSaveItem_Click(object sender, EventArgs e)
{
try
{
this.Validate();
this.tblProductBindingSource.EndEdit();
this.tableAdapterManager.UpdateAll(this.database1DataSet);
MessageBox.Show("Update temporary database1DataSet Successful");
this.tableAdapterManager.TblProductTableAdapter.Fill(this.db1ds.TblProduct);
db1ds.TblProduct.AcceptChanges();
MessageBox.Show("Update db1ds Successful??");
}
catch (System.Exception ex)
{
MessageBox.Show("Update Failed");
ex.GetBaseException();
}
//Trying to get temporary database1DataSet saved to Permenant Database1DataSet
//and eventually to the server database Database1
this.tableAdapterManager.TblProductTableAdapter.Fill(this.db1ds.TblProduct);
db1ds.TblProduct.AcceptChanges();
}
如何将更改永久保存到db1ds数据集或数据库?