private void Save() { // We have to remove all the existing data and insert the new data to save properly #region Fields _formSchema.schema_name = txtSchemaName.Text; _formSchema.data_type = (DataMappingConnectionTypes)cmbDataType.SelectedItem; _formSchema.sqlstatement = txtSQL.Text; _formSchema.server_name = txtServerName.Text; _formSchema.database_name = txtDatabaseName.Text; _formSchema.user_name = txtUserName.Text; _formSchema.allow_password_save = chkAllowSavePassword.Checked; _formSchema.claim_id_column = txtClaimIDColumn.Text; _formSchema.company_namecolumn = txtCompanyNameColumn.Text; _formSchema.date_column = txtDateColumn.Text; _formSchema.sqlstatementsecondaries = txtSQLSecondary.Text; _formSchema.sqlstatementpredeterms = txtSQLPredeterm.Text; _formSchema.claim_db_column = txtClaimDBColumn.Text; _formSchema.sqlstatementsecondarypredeterms = txtSQLSecondaryPredeterm.Text; if (chkAllowSavePassword.Checked) { _formSchema.pw = txtPassword.Text; } else { _formSchema.pw = ""; } #endregion _formSchema.Save(); _formSchema.ExecuteNonQuery("DELETE FROM data_mapping_schema_data WHERE schema_id = " + _formSchema.id); data_mapping_schema_data saveSchemaData; foreach (DataGridViewRow aRow in dgvMappings.Rows) { if (CommonFunctions.DBNullToString(aRow.Cells["colLinkedField"].Value) != "") { // Save this saveSchemaData = new data_mapping_schema_data(); saveSchemaData.mapping_field_id = ((data_mapping_field)aRow.Cells["colFieldData"].Value).id; saveSchemaData.mapped_to_text = aRow.Cells["colLinkedField"].Value.ToString(); saveSchemaData.schema_id = _formSchema.id; saveSchemaData.Save(); } } _dataChanged = false; }