Bug With GetFloat?
Jul 30, 2007
I have field defined as float (price).
when I do the following command I get invalid cast.
reader.GetFloat(reader.GetOrdinal("price"));
I have to pull it with GetDouble.
reader.GetDouble (reader.getOrdinal("price"));
which works.
since it's defined as a float would that not make this an error.. or am I missing something?
View 3 Replies
Apr 22, 2008
Hi All,
I am the following problem retrieving Float data from a Compact SQL database, it worked perfectly with 1.1 .Net CF, but since updating to 2.0 .Net CF its crashing with a "InvalidCastException" Error, have checked the DB its a Float...
// Start of code snip
cmd = conn.CreateCommand();
string cmdString ="select " +
RECORDNUMBER_COLUMN + ", "
+ FULLNAME_COLUMN + ", "
+ FPFILENAME_COLUMN + ", "
+ IMAGENAME_COLUMN + ", "
+ BMPNAME_COLUMN + ", "
+ TEMPLATENAME_COLUMN + ", "
+ SCORE_SCORE_COLUMN + " "
+ "from " + ENROLTABLE_NAME + " where " + RECORDNUMBER_COLUMN + " = " + iNumber;
cmd.CommandText = cmdString;
SqlCeDataReader DataReader = cmd.ExecuteReader(System.Data.CommandBehavior.SingleResult);
while(DataReader.Read())
{
recordnumber = DataReader.GetInt32(DS_WORD_COLUMNINDEX_RECORDNUMBER);
fullname = DataReader.GetString(DS_WORD_COLUMNINDEX_FULLNAME);
fpdataname = DataReader.GetString(DS_WORD_COLUMNINDEX_FPFILENAME);
fpimagename = DataReader.GetString(DS_WORD_COLUMNINDEX_IMAGENAME);
personbmpname = DataReader.GetString(DS_WORD_COLUMNINDEX_BMPNAME);
persontemplatename = DataReader.GetString(DS_WORD_COLUMNINDEX_TEMPLATENAME);
//*******************************************************
Score_Score = DataReader.GetFloat(DS_WORD_SCORE_COLUMNINDEX_TEMPLATESCORE);
// This generates the error : "InvalidCastException"
//*******************************************************
ReturnValue=true;
}
DataReader.Close();
conn.Dispose();
cmd.Dispose();
// End Of Snip
Cheers for any help with this
Adz
View 1 Replies
View Related