Can this be scripted?

Results 1 to 2 of 2

Thread: Can this be scripted?

  1. #1
    Zola Guest

    Default Can this be scripted?

    I have set up my Access database in such a way that the Username and password must be unique. I would like to set up a series of if else statements so that first it checks the username from request.form against the the field information.username. If they match, I want it to have an error response. I would like to do the same thing with the password, then if they are okay, I would like it to go on and add the new records.<BR><BR>I have it set up thusly:<BR><BR>(set connection and SQL statement)<BR>rsNew.open sql, conn, 3, 3<BR>rsNew.AddNew<BR>rsNew("Username") = Request.Form("Username")<BR>rsNew("Password") = Request.Form("Password")<BR>(etc. etc. etc.)<BR>If rsNew("Username") = Information.Username then&#037;&#062;<BR>blah blah blah<BR>&#060;%Else If rsNew("Password") = Information.Password Then &#037;&#062;<BR>blah blah blah<BR>&#060;% Else If rsNew.eof = False Then <BR> Username = rsNew("Username") <BR>Password = rsNew("Password")<BR>etc. etc. etc.&#037;&#062;<BR>&#060;%Else><BR>blah blah blah<BR>&#060;%end if<BR>rsNew.Update<BR>rsNew.Close<BR>set rsNew = nothing<BR>set conn = nothing&#037;&#062;<BR><BR>When I try to test it, however, I end up with this error:<BR>Microsoft VBScript compilation error &#039 800a03f6&#039 <BR><BR>Expected &#039End&#039 <BR><BR>/heart/exe-bin/charnew2.asp, line 460 <BR><BR>Am I going about this the wrong way? Is an if..then...else limited to only 3 statements?<BR><BR>TIA<BR><BR>Zola<BR>

  2. #2
    Alex Buchanan Guest

    Default RE: Can this be scripted?

    The problem is that you are using "Else If". To fix the problem, replace that with "ElseIf" (no space). <BR><BR>When Else and If are separate, they are actually two different If statements, therefore both need an "End". If you use ElseIf, it&#039s just another condition check within that same If statement.<BR><BR>There are no limitations to the If statement and your code otherwise seems fine.<BR><BR>Alex

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •