I am trying to use SQLlite for a hostel booking system created using Xamarin.Forms. I would like to search for booking records that exist between two dates of a given ID and room type.
// Count number of bookings between these dates at the hostel for the specified room type
int count = App.Database.CheckValidBooking(hostel_ID, hostel_room_type, DPickerFrom.Date, DPickerTo.Date).Count();
public List<PaidBookings> CheckValidBooking(int ID, string type, DateTime period_start, DateTime period_end)
{
return database.Query<PaidBookings>("SELECT * FROM PaidBookings WHERE ID = ? AND Type = ? AND checkIn >= ? AND checkOut <= ?;", ID, type, period_start, period_end);
}
I have an error caused by the SQL statement when executed:
public List<PaidBookings> CheckValidBooking(int ID, string type, DateTime period_start, DateTime period_end)
{
return database.Query<PaidBookings>("SELECT * FROM PaidBookings WHERE ID = ? AND Type = ? AND checkIn >= ? AND checkOut <= ?;", ID, type, period_start, period_end);
}
System.NullReferenceException: Object reference not set to an instance of an object.
How can I resolve this? Thank you.