E
eric
I have a method that queries a database table, to retrieve possible
format codes. The method is as follows:
public ArrayList GetDate(string frameSize, string partType)
{
ArrayList alAllFormats = new ArrayList();
ArrayList alDisplayFormats = new ArrayList();
OracleCommand cmdHeatCastDate = new OracleCommand("SELECT
DATE_FORMAT, "
+ "DISPLAY_TO_USER FROM DBO.CAST_INFO WHERE FRAME_SIZE='"
+ frameSize + "' AND PART_TYPE='" + partType + "'",
connMachinePartDatabase);
OpenConnection();
OracleDataReader rdrQuery;
try
{
rdrQuery = cmdHeatCastDate.ExecuteReader();
while(rdrQuery.Read())
{
try
{
if(rdrQuery.GetString(1)=="YES")
{
alAllFormats.Add(rdrQuery.GetString(0));
alDisplayFormats.Add(rdrQuery.GetString(0));
}
else
{
alAllFormats.Add(rdrQuery.GetString(0));
}
}
catch(System.InvalidCastException)
{
alAllFormats.Add("");
}
}
ArrayList heatCastDateInfo = new ArrayList();
heatCastDateInfo.Add(alDisplayFormats);
heatCastDateInfo.Add(alAllFormats);
return heatCastDateInfo;
}
catch(Exception EX)
{
throw new DataFormatException();
}
finally
{
rdrQuery.Close();
connMachinePartDatabase.Close();
}
}
My problem is that while testing/debugging, I keep getting the
following error:
{"Operation is not valid due to the current state of the object."
}
and I cannot figure out why. If I don't step through the code, then it
loads the information fine. Can anyone help me with the issue? Your
help is greatly appreciated.
format codes. The method is as follows:
public ArrayList GetDate(string frameSize, string partType)
{
ArrayList alAllFormats = new ArrayList();
ArrayList alDisplayFormats = new ArrayList();
OracleCommand cmdHeatCastDate = new OracleCommand("SELECT
DATE_FORMAT, "
+ "DISPLAY_TO_USER FROM DBO.CAST_INFO WHERE FRAME_SIZE='"
+ frameSize + "' AND PART_TYPE='" + partType + "'",
connMachinePartDatabase);
OpenConnection();
OracleDataReader rdrQuery;
try
{
rdrQuery = cmdHeatCastDate.ExecuteReader();
while(rdrQuery.Read())
{
try
{
if(rdrQuery.GetString(1)=="YES")
{
alAllFormats.Add(rdrQuery.GetString(0));
alDisplayFormats.Add(rdrQuery.GetString(0));
}
else
{
alAllFormats.Add(rdrQuery.GetString(0));
}
}
catch(System.InvalidCastException)
{
alAllFormats.Add("");
}
}
ArrayList heatCastDateInfo = new ArrayList();
heatCastDateInfo.Add(alDisplayFormats);
heatCastDateInfo.Add(alAllFormats);
return heatCastDateInfo;
}
catch(Exception EX)
{
throw new DataFormatException();
}
finally
{
rdrQuery.Close();
connMachinePartDatabase.Close();
}
}
My problem is that while testing/debugging, I keep getting the
following error:
{"Operation is not valid due to the current state of the object."
}
and I cannot figure out why. If I don't step through the code, then it
loads the information fine. Can anyone help me with the issue? Your
help is greatly appreciated.