I have a problem in this line of code:
Dim arrivalDate As Date = Request.Form("startDate")
the error is this: "Conversion from string "" to type 'Date' is not valid."
I have a problem in this line of code:
Dim arrivalDate As Date = Request.Form("startDate")
the error is this: "Conversion from string "" to type 'Date' is not valid."
You need to parse the string value to a date.
Dim arrivalDate As DateTime = DateTime.Parse(Request.Form("startDate"))
See the following MSDN for more details.
Also if you are unsure of the validity of the startDate
value (not sure if the string is actually a valid date) you can call TryParse like so:
Dim dateValue As Date
If Date.TryParse(Request.Form("startDate"), dateValue) Then
//Do something
use TryParse always to eliminate runtime exception
Dim arrivalDate As Date
Date.TryParse(Request.Form("startDate"), arrivalDate)
if the value of Request.Form("startDate")
is not a valid date then arrivalDate will have the value of Date.MinValue
So have a check before performing further operations