This query results in a syntax error. The error message makes mention of a missing operator, but I think it is a format problem with the date. I've searched the internet and all of my books and there is very little information on how to properly format a date/time query in Visual C Sharp.
This is the query that contains an error.
NOTE: I HAD TO ADD SPACES IN ORDER TO VIEW THE CODE HERE.
"SELECT DateTime FROM Events WHERE " + monthCalendar1. SelectionStart. AddDays(4). ToString() + " %26lt; DateTime"
Ive tried using "BETWEEN "+ monthCalendar1. SelectionStart. AddDays(4). ToString() +" AND DateTime"
but had the same error
there must be a problem with the format of monthCalendar1. SelectionStart. AddDays(4). ToString()
I hope there are some knowledgeable C# programmers out there with experience working with databases!
Query format for date incorrect using C#?
1) You have not specified the field in the where clause
"SELECT DateTime FROM Events WHERE FIELDNAME BETWEEN " + monthCalendar1. what ever
2) When you are using date values and passing to Sql, you need to format it
example: SELECT * FROM example WHERE exampledate between '2007-01-01'
AND '2007-06-10'
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment