Link to home
Start Free TrialLog in
Avatar of G0ggy
G0ggyFlag for United Kingdom of Great Britain and Northern Ireland

asked on

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

Avatar of dampsey
dampsey
Flag of Türkiye image

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?
Avatar of G0ggy

ASKER

No, sorry, it is the same DB server and there is no TCF block.
ASKER CERTIFIED SOLUTION
Avatar of dampsey
dampsey
Flag of Türkiye image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of G0ggy

ASKER

Yep it's the c1.startDate condition that is not working, bit confused as to why as it used to work fine?
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
Avatar of G0ggy

ASKER

Hmm, that is a concern as, eventually, this will be a global site...
Avatar of G0ggy

ASKER

I solved with using getDate(), how simple, how annoying, you can have the points for getting me in the right direction, cheers.
thanks ;)