問題是 - 程序運行時,我更改,添加和刪除datagrid中的數據。 但是,當我重新啓動我的程序 - 它從數據庫加載所有數據沒有任何改變(只添加數據)。程序中的任何更改都不會影響數據庫
哪裏有問題?
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);
}
}
發佈一些代碼來說明問題。 –
任何數量的地方。很可能,您沒有運行任何命令返回數據庫來更新數據庫。發佈你的代碼,我們可以幫忙。 – AllenG
發佈你的代碼和詳細說明可能會得到一些消極的否定。 –