Hi, so i have a table in my database called open_hours, containing the open time and closing time (saved as type time) of a venue for each day of the week. Im making a booking system so i want to be able to check if the booking times entered by the user are within the open hours.
Try
mysqlconn.Open()
query = "SELECT* FROM open_hours WHERE day='" & Datetimepicker1.Value.DayOfWeek.ToString & "'"
MsgBox(query)
command = New MySqlCommand(query, mysqlconn)
reader = command.ExecuteReader
While reader.Read()
If start_time.value < reader.GetDateTime("open_time") Or end_time.value > reader.GetDateTime("close_time") Then
errors.Enqueue("The booking must be within the opening times")
End If
End While
mysqlconn.Close()
Catch ex As Exception
MsgBox(ex.Message)
Finally
mysqlconn.Dispose()
End Try
So this is what i have so far however, when i click the button to check the bookings availabliity, i get an error message say "Unable to convert MYSQL date/time value to system.datetime".
Now, i've googled this error message and the general solution if to add Convert Zero Datetime=True to the connection string.
mysqlconn.ConnectionString = "Server=localhost;userid=root;password=root;database=comp4;Convert Zero Datetime=True"
When i do this, i do get a value for the open_time, but its just 00:00:00.
None of my open times are 00:00:00 so i dont understand whats going on.
Please help, this is driving me crazy!!