Posted 6 years ago
·
Author
I have a C# Windows App and I am trying to code up a Save Button. I have no errors in my code; however, my dataset is not saving changes. Any suggestions would be appreciated.
Thank you guys so much
private void SaveButton_Click_1(object sender, EventArgs e)
{
try
{
dataTable1BindingSource1.EndEdit();
App.DataTable1.WriteXml(string.Format("{0}//data.dat", Application.StartupPath));
MessageBox.Show("Save Complete");
groupBox3.Enabled = false;
grpBxReportedBy.Enabled = false;
groupBox1.Enabled = false;
App.DataTable1.AcceptChanges();
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "Messages", MessageBoxButtons.OK, MessageBoxIcon.Error);
App.DataTable1.RejectChanges();
}
}
static DataSet1 db;
protected static DataSet1 App
{
get
{
if (db == null)
db = new DataSet1();
return db;
}
}
private void FascilitiesMaint2018_Load(object sender, EventArgs e)
{
string fileName = string.Format("{0}//data.dat", Application.StartupPath);
if (File.Exists(fileName))
{
App.DataTable1.ReadXml(fileName);
}
dataTable1BindingSource1.DataSource = App.DataTable1;
groupBox3.Enabled = false;
grpBxReportedBy.Enabled = false;
groupBox1.Enabled = false;
}
Thank you guys so much