casting Error

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi

I'm trying to put the database column's value in a
variable, but when I do this I get this exception
Specified cast is not valid.

The column accept varchar values. My code is:

string reg = odrCrear.GetString("Name").ToString().Trim();

What is wrong???

Regards
 
I'm trying to put the database column's value in a
variable, but when I do this I get this exception
Specified cast is not valid.

The column accept varchar values. My code is:

string reg = odrCrear.GetString("Name").ToString().Trim();

What is wrong???

I suggest you use GetValue and look at the type of the returned object
- just to find out what it is, for testing purposes. If the column is a
varchar, I'd expect it to be a string, but apparently it isn't.

(What are you expecting the call to ToString() to do there, by the
way?)
 
Back
Top