0
string sqlStatement = "select ID, Checkintime, RoomPrice, OrderNo from Orders where RoomType='" + selectedRoom.Key + "' and RoomNumber=" + selectedRoom.Value + " and Checkintime>="+dateOnly+" and CheckinTime<'"+endingTime+"'"; 

myAccessCommand = new OleDbCommand(sqlStatement, myAccessConn);
OleDbDataAdapter myDataAdapter = new OleDbDataAdapter(myAccessCommand);
myDataAdapter.Fill(myDataSet, "Orders");

I have syntax error in the SQL statement line but I am not sure what went wrong that caused an syntax exception.

2

1 Answer 1

2

Short fix: change

Checkintime>="+dateOnly+" 

to

Checkintime>='"+dateOnly+"'

(you forgot the tick marks in the first reference to Checkintime)


Much better: Use a parameterized query

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.