public void queryPrimaryWS() { DB2Connection conndb2 = new DB2Connection(globalConnStringDb2); try { conndb2.Open(); DB2Command cmd = conndb2.CreateCommand(); DB2Transaction trans = conndb2.BeginTransaction(); cmd.Transaction = trans; cmd.CommandText = "" + rtPrimaryWS.Text; tbPrimWS.Text = cmd.ExecuteScalar().ToString(); string strLog = System.DateTime.Today.ToShortDateString() + " LOG : Ran TA00WB.WORK_SUMMARY Query. " + tbPrimWS.Text + " rows returned.@"; strLog = strLog.Replace("@", "" + System.Environment.NewLine); rtLogging.AppendText(strLog); //logger string logFilePath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments); using (TextWriter outputFile = new StreamWriter(logFilePath + @"\WBArchiving.txt", true)) { outputFile.Write(strLog); } conndb2.Close(); } catch (Exception e) { tbPrimWS.Text = " "; MessageBox.Show("An error was encountered during runtime. Please try again.\n\n" + e.GetBaseException().Message, "TA00WB.WORK_SUMMARY Error", MessageBoxButtons.OK, MessageBoxIcon.Error); string strArchWSLog = System.DateTime.Today.ToShortDateString() + " LOG : Ran TA00WB.WORK_SUMMARY Query. Error occured. No" + tbPrimWS.Text + "rows returned.@"; strArchWSLog = strArchWSLog.Replace("@", "" + System.Environment.NewLine); rtLogging.AppendText(strArchWSLog); }//catch }
public void queryBoundaryDate() { DB2Connection conndb2 = new DB2Connection(globalConnStringDb2); try { conndb2.Open(); DB2Command cmd = conndb2.CreateCommand(); DB2Transaction trans = conndb2.BeginTransaction(); cmd.Transaction = trans; cmd.CommandText = "" + rtCheckBoundary.Text; tbBoundaryDate.Text = cmd.ExecuteScalar().ToString(); string strBoundaryLog = System.DateTime.Today.ToShortDateString() + " LOG : Ran Archive Boundary Query. Current boundary date is " + tbBoundaryDate.Text + "@" ; strBoundaryLog = strBoundaryLog.Replace("@", "" + System.Environment.NewLine); rtLogging.AppendText(strBoundaryLog); conndb2.Close(); } catch (Exception e) { MessageBox.Show("An error was encountered during runtime. Please try again.\n\n" + e.GetBaseException().Message, "Check Archive Boundary Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }