tags:

views:

33

answers:

2
set rs5 = objconn.execute("Select Sing from LeaveEntitlement where MonthEntitle = '"& Month(ttodate)& " ' ")                
do until rs5.eof   
  if rs5("Sing") then   
  s = rs5("Sing")  
Loop

In the Database table LeaveEntitlement, MonthEntitle is a Field Nmae(Text Data type) from January...December.Sing is another Field(Number Data type) with values for each Month.But S is returning nothing.

Can help for solving this.

Oded, Thanks a lot for solving my issue.

+1  A: 

There are probably no rows in the table corresponding to the month you are searching on.

Have you checked directly against the database that the query is returning any rows?

Edit:

It appears that you are using month names in your database, however the Month function returns a month number. You are enclosing that in ', so you are sending a string with the number in the query - this is why you do not get a type error and why no results are being returned.

You can use MonthName with Month:

where MonthEntitle = '" & MonthName(Month(ttodate)) & "' "
Oded
Yes,When checked in the database,query returns the value
KSCD
Have you checked the _actual_ query as it comes from your asp page?
Oded
Not returning with asp code
KSCD
@KSCD - Take a look at the query as it comes from asp and compare to the one that works. That should highlight what is not working.
Oded
Is it because datatype for Month entitled is Text.In the asp code iam comparing against Month
KSCD
But iam not getting any Datatype Mismatch Error.But the value is not retrieving.
KSCD
@KSCD - The asp `Month` function returns a number - you are essentially doing `where MonthEntitle = '7'` for example.
Oded
Yes,But the MonthEntitle is having a datatype text as January..December
KSCD
or even if i change MonthEntitle Datatype to Number(1,2,....,12).Still not retrieving
KSCD
@KSCD - did you read my last update? You can pass in the month name.
Oded
+2  A: 

Just taking a stab in the dark it looks like you have an extra space at the end of your sql where you put in the month name. Probably not matching any records.

spinon
good idea! nice eye
JSmaga
That is just typing error.
KSCD
Can you confirm that the application is returning rows using that sql statement in your application? What I'm saying is are you certain that you are even getting inside the do loop?
spinon