开发者

Error in ASP Code

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 leav开发者_开发知识库ebank (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


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜