Specified cast is not valid
335359Apr 16 2004 — edited Mar 8 2010I am using 9i and ODP.Net and this error is driving me crazy... The column in question is an Integer named MAJCOM_ID...
I validated that I am in fact getting data from my reader. Here is my method:
public MajcomInfo(int id, string name, string longname)
{
this._majcomId = id;
this._majcomName = name;
this._majcomLongName = longname;
}
here is my reader:
while (rdr.Read())
{
int id = 0;
if (rdr.IsDBNull(0))
{
string mystring = null;
mystring = "no data";
}
else
{
id = rdr.GetInt32(0);
}
string strName = rdr.GetString(1);
string strLongName = rdr.GetString(1);
MajcomInfo majcom = new MajcomInfo(id, strName, strLongName);
allMajcoms.Add(majcom);
}
I have tried to convert this to Int32 by Convert.Int32(id = rdr.GetInt32(0)); and I get the same error..