I don't understand this error.

  • Thread starter Thread starter eric
  • Start date Start date
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top