tags:

views:

37

answers:

1

Hi

Below ASP code have some error in 'Dim MonthNum=Month("Ctxtdatefrom") ' Can help to solve this.

If session("cmbLeaveType")=2 then

    set rs2 = objconn.execute("select * form Particulars where empid='" & session("empid") & "'") 

    if Nationality = ABC then

        Dim MonthNum=Month("Ctxtdatefrom")
        Dim MonthNum2=Month("ctxtdateto")

        If(MonthNum=5 and monthnum2=5)
            if tdays>1 then

            else
                set rs = objconn.execute("insert into leavebank (empid, datesubmit, datefrom, dateto....
            END IF 
        END IF 
    END IF 
END IF 

If Nationality is "Country A" ,Number of Leave allowed to take on 5th month is 1.

If(MonthNum=5 and monthnum2=5)

if tdays>1 then

-> Can you please correct

+1  A: 

I'm guessing that you are seeing an error like:

Microsoft VBScript compilation error '800a0401' 

Expected end of statement 

/test.asp, line 11 

Dim MonthNum = Month("Ctxtdatefrom") 
-------------^

This error is being thrown because you cannot dim and assign in one line in VBScript.

If you rewrite that to:

Dim MonthNum
MonthNum = Month("Ctxtdatefrom") 

You will be closer to your aim - though you will then almost certainly hit another error - your call to the month function does not do what you think it does.

By wrapping your variable Ctxtdatefrom in double quotes you are actually passing a literal string containing the value Ctxtdatefrom to the VBScript Month function.

What you want to do is:

Dim MonthNum
MonthNum = Month(Ctxtdatefrom) 

That should work so long as that variable contains a valid VBScript date format.

You can find some reading here.

The above said - based on your code, you are almost certainly going to see more errors, I'd recommend you find someone who can mentor you in ASP classic and VBScript, read some online tutorials or take things one step at a time and post detailed and specific questions here.

David Hall
+1 for the good description and some education..
ydobonmai