In my c# code, I have a double that I am trying to set to the value that is in my SQL Management 2008 R2 database that is of type float (which corresponds to a double in c#, right?). When I use this syntax
double x = (double)reader["column1"]; //reader is SqlDataReader object
I get the error “specified cast is not valid.”
What gives?
I would suggest using the helper classes available through the SqlDataReader object…
If there is a chance the column could be null, you should account for that…