Inconsistent results from command object

Hi all,

I'm looking for pointers here. I have a command which is generated from search options, if I run the command from within my website I get an empty datareader, if I then copy the SQL from SQL Profiler and paste it into a new query window in SQL Server Management Studio I get 1 result back.

How is it possible to have different results from the same command?

TIA.
SELECT cl.classID, cl.country, co.countryName, cl.courseID, cm.courseName, cl.startDate, cl.endDate, cl.startTime, cl.endTime, cl.noOfDays, cl.maxDelegates, cl.location, dp.DepotName, cl.extraDetails, cl.instructor, mu.firstName + 
' ' + mu.familyName As instructorFullName, cl.hiddenFromDealersStaff, cl.assessmentOptions, cl.createdBy, mu2.firstName + ' ' + mu2.familyName As createdByFullName, cl.createdDate, cl.editedBy, mu3.firstName + ' ' + mu3.familyName 
As editedByFullName, cl.lastEditedDate FROM dbo.trn_classes cl Inner Join dbo.usr_countries co On cl.country = co.id Inner Join dbo.trn_coursesMaster cm On cl.courseID = cm.courseID Left Outer Join dbo.usr_depots dp On cl.location 
= dp.DepotID Left Outer Join dbo.usr_masterUsers mu On cl.instructor = mu.profileID Left Outer Join dbo.usr_masterUsers mu2 On cl.createdBy = mu2.profileID Left Outer Join dbo.usr_masterUsers mu3 On cl.editedBy = mu3.profileID 
Where cm.courseName Like '%basic%'  And cl.classStatus = 1  And cl.startDate > Cast('2008-02-11 00:00:00.000' As DateTime)

Open in new window

LVL 11
G0ggyAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
dampseyConnect With a Mentor Commented:
can you please try without the c1.startDate condition?
0
 
dampseyCommented:
do you have any try catch blocks with an empty catch? if this is the case, you may get an exception but don't be notified???

or check your connection string may be your are connecting to a different server? with a unupdated data with the same structure?
0
 
G0ggyAuthor Commented:
No, sorry, it is the same DB server and there is no TCF block.
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
G0ggyAuthor Commented:
Yep it's the c1.startDate condition that is not working, bit confused as to why as it used to work fine?
0
 
dampseyCommented:
this may be because of your reginal settings may be?
you know. the most problamatic thing with dates are
year, month, day
or
year, day, month
0
 
G0ggyAuthor Commented:
Hmm, that is a concern as, eventually, this will be a global site...
0
 
G0ggyAuthor Commented:
I solved with using getDate(), how simple, how annoying, you can have the points for getting me in the right direction, cheers.
0
 
dampseyCommented:
thanks ;)
0
All Courses

From novice to tech pro — start learning today.