// method to update and write data public void SaveData() { // make table adapters ProjectDatabaseDataSetTableAdapters.EmployeesTableAdapter taEmployees = new ProjectDatabaseDataSetTableAdapters.EmployeesTableAdapter(); ProjectDatabaseDataSetTableAdapters.StatusTableAdapter taStatus = new ProjectDatabaseDataSetTableAdapters.StatusTableAdapter(); ProjectDatabaseDataSetTableAdapters.ProjectsTableAdapter taProjects = new ProjectDatabaseDataSetTableAdapters.ProjectsTableAdapter(); ProjectDatabaseDataSetTableAdapters.TasksTableAdapter taTasks = new ProjectDatabaseDataSetTableAdapters.TasksTableAdapter(); ProjectDatabaseDataSetTableAdapters.WorkTableAdapter taWork = new ProjectDatabaseDataSetTableAdapters.WorkTableAdapter(); //make table adapter manager and connect to table adapters ProjectDatabaseDataSetTableAdapters.TableAdapterManager taManager = new ProjectDatabaseDataSetTableAdapters.TableAdapterManager(); taManager.EmployeesTableAdapter = taEmployees; taManager.StatusTableAdapter = taStatus; taManager.ProjectsTableAdapter = taProjects; taManager.TasksTableAdapter = taTasks; taManager.WorkTableAdapter = taWork; try { taManager.UpdateAll(Project); } catch (Exception ex) { SetReady(ex.Message); } }
// fills all table data using the adapter private void GetData() { // make table adapters ProjectDatabaseDataSetTableAdapters.EmployeesTableAdapter taEmployees = new ProjectDatabaseDataSetTableAdapters.EmployeesTableAdapter(); ProjectDatabaseDataSetTableAdapters.StatusTableAdapter taStatus = new ProjectDatabaseDataSetTableAdapters.StatusTableAdapter(); ProjectDatabaseDataSetTableAdapters.ProjectsTableAdapter taProjects = new ProjectDatabaseDataSetTableAdapters.ProjectsTableAdapter(); ProjectDatabaseDataSetTableAdapters.TasksTableAdapter taTasks = new ProjectDatabaseDataSetTableAdapters.TasksTableAdapter(); ProjectDatabaseDataSetTableAdapters.WorkTableAdapter taWork = new ProjectDatabaseDataSetTableAdapters.WorkTableAdapter(); try { taEmployees.Fill(Project.Employees); taStatus.Fill(Project.Status); taProjects.Fill(Project.Projects); taTasks.Fill(Project.Tasks); taWork.Fill(Project.Work); } catch (Exception ex) { // shows message in status label SetReady(ex.Message); } }