Environment Mono, PostgreSQL, .Net MVC, Windows
I'm try to show all events that occur in the future.
In order to do that I'm using the following SQL:
NpgsqlCommand command = new NpgsqlCommand("SELECT * FROM dinners WHERE EventDate >= " + DateTime.Now, dinnerConn);
Now, if I compare DateTime.Now and my EventDate timestamp from the DB, I get the following
(EventDate) 12/18/2010 7:00:00 PM - (DateTime.Now) 10/2/2010 7:59:48 PM
They seem pretty easily comparable to me, but whenever I run this query, I get the following:
ERROR: 42601: syntax error at or near "8"
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: Npgsql.NpgsqlException: ERROR: 42601: syntax error at or near "8"
Source Error:
Line 106: try
Line 107: {
Line 108: NpgsqlDataReader reader = command.ExecuteReader();
Line 109: while (reader.Read())
Line 110: {
Source File: c:\Documents and Settings\Andrew\My Documents\Visual Studio 2008\Projects\MvcApplication1\MvcApplication1\Models\DBConnect.cs Line: 108
Now, I know the application works otherwise because if I ask it to pull all dinners, or all dinners greater than a specific ID, or a specific dinner, everything works fine, it just seems to be trying to compare timestamp to DateTime.Now.
I know this is something simple. What am I doing wrong?