I'm trying to Select data from a table using OLEDB
Libraries - Essentially I have a date range both dates in fields within a record (Access), I also have another field which is needed to select data.
I have a local variable holding date/time information, I need to output the data where that value held in the variable is in range with the two dates in a record, and the record holds another value which will be compared against a local variable. Any help, just showing basic syntax and querying would be appreciated.
I've looked for comparing and querying between date ranges and have had no luck.
cmd.CommandText = "SELECT FirstName, LastName, Email, PhoneNumber,
NumberOfGuests, StartDate, NumberOfNights, Breakfast,
RoomType, EmployeeName, Comments FROM Booking WHERE
StartDate <= " + dtpRoomSearch.Value + "AND +
EndDate >= dtpRoomSearch.Value;
Need to output this information as a string (Excuse Bad Syntax, I don't know where I should be putting speech marks etc.)
I need to Query using both Local Variables and Values held in the fields of a table i.e. StartDate ( addressing field in table ) and EndDate (Addressing Field in table compared with local values. Also, how would I go about structuring the syntax?