p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


  Return to Index  

asp_databases thread: Problem with If Elseif statements


Message #1 by "Ben Lew" <formula1@b...> on Mon, 10 Jul 2000 6:18:43
I have a problem that has been vexing me for several days.  I have a 

database that will hold a set of three different shipping addresses for 

customers.  In my asp page, I retrieve the fields for these address through 

the standard connection and recordset object, then I set the addresses 

equal to address1, address2, and address3 respectively.  I have an 

if-elseif statement that determines if any of the address fields are empty 

and if so to have a form that allows the user to add an address to his 

user_id.  I am using the following if-else statement:



If not address1<>"" and not address2<>"" and not address3<>"" Then%>

New Address form

<form action="NewAddress.asp" method="post">

<input type="submit" value="Add New Address">

<input type="hidden" name="newAddressTrigger" value="1">

</form>

<%

ElseIf not address1<>"" then

%>

Existing Address Form

<form action="NewAddress.asp" method="post">

<input type="submit" value="Add New Address">

</form>

<%

Elseif not address2<>"" then

%>

Existing Address Form

<form action="NewAddress.asp" method="post">

<input type="submit" value="Add New Address">

</form>

<%

ElseIf not address3<>"" then

%>

Existing Address Form

<form action="NewAddress.asp" method="post">

<input type="submit" value="Add New Address">

</form>



<%

Else

%>

do nothing here

<%

End If 





Soooo, if any of the addresses are empty a buttons should show up to allow 

a new address to be submitted.  However, once the first address is added, 

this loop constantly does not work, and instead just says "Do nothing here" 

which is my test to see if the loop is even running.  I've also printed out 

the values for address1, address2 and address3 and they show that my 

recordset if returning empty fields for address2 and address 3.  I've tried 

using ="" instead of not<>"" also and same result.  Can anyone help me out? 

 BTW, I am using SQL Server 7.0 as the backend and PWS on an NT Workstation 

machine to prototype this.




  Return to Index