These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: query returns no data
PostPosted: Tue Dec 22, 2009 10:25 am 
Newbie

Joined: Thu Dec 03, 2009 2:10 pm
Posts: 13
Hello,
I have a c# app that is trying to return data from a mysql database with criteria between two dates. I have the following code set up -

Code:
public IList<myObject> GetmyObjectBetweenDateRange(DateTime fromDate, DateTime toDate)
        {
            return _session.CreateCriteria(typeof(myObject))
                .Add(Expression.Gt("dateTime", fromDate))
                .Add(Expression.Lt("dateTime", toDate))
                .List<myObject>();
        }


This code is not returning any data. I have my config file set to show sql. below is the sql that is running (from the output window) -
Code:
NHibernate: SELECT this_.he_id as he1_0_0_, this_.he_dateTime as he2_0_0_, this_.he_clocation_id as he3_0_0_, this_.he_nact_length as he5_0_0_, this_.he_order as he6_0_0_, this_.he_ntype as he7_0_0_, this_.he_roomid as he8_0_0_,  FROM myTable this_ WHERE this_.he_dateTime > ?p0 and this_.he_dateTime < ?p1 ;?p0 = 12/1/2009 12:00:00 AM, ?p1 = 12/21/2009 12:00:00 AM


I run this in the query window as the following query -
Code:
SELECT this_.he_id as he1_0_0_, this_.he_dateTime as he2_0_0_, this_.he_clocation_id as he3_0_0_,  this_.he_order as he6_0_0_, this_.he_ntype as he7_0_0_, this_.he_roomid as he8_0_0_, this_.he_mftrlogsheetname as he9_0_0_, this_.he_ccalendar_num as he10_0_0_ FROM myTable this_ WHERE this_.he_dateTime > '12/1/2009 12:00:00 AM' and this_.he_dateTime < '12/21/2009 12:00:00 AM'


When I run the query, I am getting the expected result set. does anyone have any idea why I am able to run the query in the query window for mySql and get the expected data, but when the query is run in the application, I am getting no data.

Thanks for any thougths


Top
 Profile  
 
 Post subject: Re: query returns no data
PostPosted: Tue Dec 22, 2009 3:41 pm 
Newbie

Joined: Thu Dec 03, 2009 2:10 pm
Posts: 13
It turns out that it was a datatype error at the database level. The date field I was attempting to filter on was a varchar in the db.

I changed it and everything works now.

Thanks


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.