0

Sorry, the title may not look/sound meaningful, that seems to be the best I can come up with.

I have an application with the code below as part of it which was working fine until today and I seems not to be able to figure out what the problem is. Each time the application gets to this spot, it just stays in limbo for ever without any error, warning, or progress.

private static Boolean PeriodEndingInTable(DateTime PeriodEnding, string TableName)
{
Boolean MyReturn = false;
OleDbCommand MyOleDbCommand;
string CommandString = @"SELECT Count(AC_PRD_END_DT) " +
@"FROM " + TableName + " " +
@"WHERE (((AC_PRD_END_DT)=#" + PeriodEnding.ToShortDateString() + "#))";
MyOleDbCommand = new OleDbCommand(CommandString, MyBasicEmployeeTableAdapter.Connection);

if (MyBasicEmployeeTableAdapter.Connection.State == System.Data.ConnectionState.Closed)
{
MyBasicEmployeeTableAdapter.Connection.Open();
}

MyReturn = (Int32.Parse(MyOleDbCommand.ExecuteScalar().ToString()) > 0);

// The following commented code was initroduced in replacement of 
// line immediately above but the result is the same.   

/*
OleDbDataReader rdr= MyOleDbCommand.ExecuteReader();
string rCount="0";
while (rdr.Read())
{
rCount = rdr[0].ToString();
}
rdr.Close();           

MyReturn = (Int32.Parse(rCount) > 0 ? true : false); */

return MyReturn;
}

I have stepped through the codes, run the oledbcommand string directly from the MSAccess, and validate the connectionstring are all perfectly fine. I honestly do not know what the issue. I have also turned ON all the exception settings to see if the error is just skipping and I get nothing. I desperately need help. You are much appreciated for your time and suggestions.

Ibroshine
  • 13
  • 4

1 Answers1

0

Thanks, I seem to figure out the issue. Network connection was the main cause as it was about the 'month-end close period' in my company and traffic on our network was at it peak. Plus there are about 16 tables with large number of rows that need some of the tables to be iterated a record at a time. It definitely open door for performance improvement and possible logic refactoring.

Ibroshine
  • 13
  • 4