The problem is – while program is working I change, add and delete data in datagrid.
But when I restart my program – it loads from database all data without any changes.(only add data works).
Where can be problem?
public partial class StudentsTable : Window
{
public StudentsTable()
{
InitializeComponent();
}
CourseWorkFinal.University0DataSet university0DataSet;
CourseWorkFinal.University0DataSetTableAdapters.StudentsTableAdapter university0DataSetStudentsTableAdapter;
private void Window_Loaded(object sender, RoutedEventArgs e)
{
university0DataSet = ((CourseWorkFinal.University0DataSet)(this.FindResource("university0DataSet")));
university0DataSetStudentsTableAdapter = new CourseWorkFinal.University0DataSetTableAdapters.StudentsTableAdapter();
university0DataSetStudentsTableAdapter.Fill(university0DataSet.Students);
System.Windows.Data.CollectionViewSource studentsViewSource = ((System.Windows.Data.CollectionViewSource)(this.FindResource("studentsViewSource")));
studentsViewSource.View.MoveCurrentToFirst();
university0DataSet.Students.StudentsRowChanged += new University0DataSet.StudentsRowChangeEventHandler(Modify);
university0DataSet.Students.StudentsRowDeleted +=
new University0DataSet.StudentsRowChangeEventHandler(Modify);
}
void Modify(object sender, University0DataSet.StudentsRowChangeEvent e)
{
university0DataSetStudentsTableAdapter.Update(university0DataSet.Students);
}
private void button1_Click(object sender, RoutedEventArgs e)
{
AddStudent x = new AddStudent();
x.Show();
}
private void button2_Click(object sender, RoutedEventArgs e)
{
// university0DataSetStudentsTableAdapter.Update(university0DataSet.Students);
}
}
Either you are not committing the changes or you are using some sort of instance database that is part of your project, and thus being overwritten with the original database each time you compile/run from Visual Studio.
Will need to give more details on how you have your database setup in order to give a better answer.