Link to home
Start Free TrialLog in
Avatar of rmmarsh
rmmarshFlag for United States of America

asked on

Specified cast is not valid?

This is my statement:  
if ((byte)data["TranC"] == 'A')

Open in new window


The field is defined as "char" in a Firebird table. How should I cast this?
ASKER CERTIFIED SOLUTION
Avatar of p_davis
p_davis

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rmmarsh

ASKER

I did it without the cast, and I did it with the "int" cast... either way, I get the error "Specified cast is not valid".

And then I did this:  if (int.Parse(data["TranC"].ToString()) == 'A')

and the CLR tells me the input string was not in the correct format!

Any other suggestions?
Avatar of p_davis
p_davis

did you try the

data["TranC"].ToString() == "A";//?
Avatar of rmmarsh

ASKER

I'm going to give you the points because you were very close... this is what I wound up doing:

 shipping = uint.Parse(data["Shipping"].ToString());

And it appears to be working... thank you for the time...