I am having issues with displaying from a float SQL data type onto my textbox. So far I can get strings to display just fine as well as int data types. When it comes to floats or even decimals it wants to throw a fit and I'm not entirely sure why. Here is the error I'm getting:
Cannot implicitly convert type 'float' to 'int'. An explicit conversion exists (are you missing a cast?)
How do I force ships.Height = (float)shipReader["HeightTest"]; to be a float and not an int because if I just left it as with an int it still won't display it without throwing an error. Which when you run it it will pop an error message,"Specified cast is not valid."
SqlDataReader shipReader =
selectCommand.ExecuteReader(CommandBehavior.SingleRow);
if(shipReader.Read())
{
Ships ships = new Ships();
ships.Role = shipReader["Role"].ToString();
ships.Description = shipReader["Description"].ToString();
ships.NullCargoMass = (int)shipReader["NullCargoMass"];
ships.Height = (float)shipReader["HeightTest"];
return ships;
}