private void buttonApplySchema_Click(object sender, RoutedEventArgs e) { Db2SourceContext ctx = Target.Context; List <string> sqls = new List <string>(); if ((Target.Comment != null) && Target.Comment.IsModified()) { sqls.AddRange(ctx.GetSQL(Target.Comment, string.Empty, string.Empty, 0, false)); } for (int i = 0; i < Target.Columns.Count; i++) { Column newC = Target.Columns[i, false]; if (newC.IsModified()) { Column oldC = Target.Columns[i, true]; sqls.AddRange(ctx.GetAlterColumnSQL(newC, oldC)); } if ((newC.Comment != null) && newC.Comment.IsModified()) { sqls.AddRange(ctx.GetSQL(newC.Comment, string.Empty, string.Empty, 0, false)); } } if (sqls.Count != 0) { ctx.ExecSqlsWithLog(sqls); } ctx.Revert(Target); IsEditing = false; }
private void buttonApplyTrigger_Click(object sender, RoutedEventArgs e) { if (Target == null) { IsEditing = false; return; } Db2SourceContext ctx = Target.Context; string[] sqls = Target.GetAlterSQL(string.Empty, string.Empty, 0, false); if (sqls == null || sqls.Length == 0) { return; } try { ctx.ExecSqlsWithLog(sqls); } catch (Exception t) { string recoverMsg = "(修復しました)"; string[] s = Target.GetRecoverSQL(string.Empty, string.Empty, 0, false); if (s != null && s.Length != 0) { try { ctx.ExecSqlsWithLog(s); } catch (Exception t2) { recoverMsg = string.Format("(修復失敗: {0})", ctx.GetExceptionMessage(t2)); } } MessageBox.Show(string.Format("エラー: {0}{1}", ctx.GetExceptionMessage(t), recoverMsg)); } }