Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Specified cast is not valid

335359Apr 16 2004 — edited Mar 8 2010
I 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..
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 5 2010
Added on Apr 16 2004
5 comments
11,430 views