The error comes around "NoOfRooms" there is also another textbox called "NoOfDays" which is the same. If 1 of the textbox has value the other will pop the error below however if both them have a value the program works fine.. I don't know how to make 1 work only without the error.
An unhandled exception of type 'System.FormatException' occurred in mscorlib.dll
Additional information: Input string was not in a correct format.
int NoOfRooms = 0;
double NoOfNights = 0;
NoOfRooms = Convert.ToInt32(txtNoRooms.Text);
NoOfNights = Convert.ToDouble(txtNoNights.Text);
totalCostHotel = (totalCostHotel * NoOfRooms) * NoOfNights;
{
SqlCommand command = new SqlCommand("INSERT INTO [HotelData] (RoomType, NoOfRooms, NoOfNights, totalCostHotel)"+
"VALUES (@RoomType, @NoOfRooms, @NoOfNights, @totalCostHotel)", connection);
connection.Open();
command.Parameters.AddWithValue("@RoomType", RoomType);
command.Parameters.AddWithValue("@NoOfRooms", NoOfRooms);
command.ExecuteNonQuery();
connection.Close();