I'm using the OleDb libraries to connect to an Access database. The following code in one of my <select> statement's WHERE clauses works correctly (i.e. ConcertDate is filtered corrected based on the StartDate variable):
(Concert.ConcertDate = #StartDate:Date#) When I add dynamic sql into the statement (Concert.ConcertDate = #StartDate:Date#) <isNotEmpty prepend="AND" property="EndDate"> (Concert.ConcertDate = #EndDate:Date#) </isNotEmpty> I recieve the following error: [OleDbException (0x80040e07): Data type mismatch in criteria expression.] The exception occurs when EndDate exists in the Hashtable: map["EndDate"] = DateTime.Now; and when it doesn't exist in the Hashtable: if (DateTime.Now == DateTime.MinValue) { // EndDate will never be added to the param object map["EndDate"] = DateTime.Now; } I haven't had any other problems dealing with dates in sql maps. The StartDate and EndDate columns are both Date/Time in Access. I have several other Date/Time columns such as DateAdded and DateLastUpdated that I'm able to work with without issue. I think the problem has to do with how the dynamic sql is parsed. I'm currently using: IBatisNet.DataMapper [assembly: AssemblyVersion("1.1.458")] My sloppy work around for the moment is use a function call in Access to convert a string into a Date/Time. (Concert.ConcertDate = DateValue("$StartDate$")) <isNotEmpty prepend="AND" property="EndDate"> (Concert.ConcertDate = DateValue("$EndDate$")) </isNotEmpty> Ideas? - Ron P.S. I'm actually using >= and <= for my date range searching instead of just = but that's not an issue becuase the exception occurs in both cases.