ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old November 5th, 2003, 04:59 AM
leeolive leeolive is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: London
Posts: 43 leeolive User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
if - else if - else if - confused

Hi

I can't seem to get this working, if anyone has any idea..

I need to do the following:

if str = "" or str = "" or str = "" then
print this table saying - please complete form

else
set up the connection and retrieve all data where NI = NI or UN = UN or PW = PW OR Email = Email

if no records found then user not in db so submit to db

else if records found then (check individually for which record has been found)

if NI = rsNI then
print this table saying you are already registered

else if UN = rsUN then
print this table saying enter a different UN

else if PW = rsPW then
print this table saying enter a different PW

else if Email = rsEmail then
print this table saying email already in use

<%end if%>
<%end if%>

Should I use a select case here? Confused.
Thanks Lee

Reply With Quote
  #2  
Old November 5th, 2003, 08:49 AM
williamcrawley williamcrawley is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: uk
Posts: 91 williamcrawley User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
looks to me as if you are missing another End IF.

Also the 'Else if' Statement needs to be 'ElseIf'

Reply With Quote
  #3  
Old November 5th, 2003, 08:50 AM
Pain Pain is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Sheffield, UK
Posts: 94 Pain User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via ICQ to Pain
Hmm, it seems overly complicated i'd agree..

Cant you just do it like this?

Dim condition1,condition2,condition3
condition1 = somevalue
condition2 = somevalue
condition3 = somevalue

If condition 1 = somevalue then
do stuff you want to happen here
else
do stuff you want to happen if it doesn = somevalue here
end if

if condition2 = etc etc..

at least then you'll be sure you've got it right and then once you have, you can start playing by concatinating results (if condition1 and condition 2 or condition 3 = somevalue then blah blah)

Chris

Reply With Quote
  #4  
Old November 5th, 2003, 08:51 AM
Pain Pain is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Sheffield, UK
Posts: 94 Pain User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via ICQ to Pain
(incidentally it helps that if you have code that bugs, to paste it up, rather than try doing the translation into plain english and hoping for the best..)

Reply With Quote
  #5  
Old November 5th, 2003, 02:17 PM
leeolive leeolive is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: London
Posts: 43 leeolive User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Thanks for getting back. I think someone needs to take a look at my code. The dim condition formula recommended looks interesting but I need to see a correctly written example as not sure how to write the condition??

Here's my code - hope this helps

if strContractedInIndicator = "" or strFirstName = "" then
%>
<table>
this says : please enter required text
</table>

<%response.end
else
strContractedInIndicator = "0"

'set command and establish connection
Set cndb = server.CreateObject("adodb.connection")
Set cmdcheckuser = server.CreateObject("adodb.command")
Set cmdaddtodatabase = server.CreateObject("adodb.command")
Set cmdretrievefromdb = server.CreateObject("adodb.command")
Set rsrecordsretrieved = server.CreateObject("adodb.recordset")
Set rscheckuser = server.CreateObject("adodb.recordset")

'set connection to local DNS or change to web host DNS
cndb.CommandTimeout = 15
cndb.CursorLocation = adUseServer
cndb.ConnectionString = "DSN=cjrcls" 'this is for local
'cndb.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=mydatasourcehere.mdb"
on error resume next
cndb.Mode = 3 '3 = adModeReadWrite
cndb.open

if err <> 0 then
response.write "Error connecting to the database"
response.end
end if

With cmdcheckuser
.CommandTimeout = 15
set .ActiveConnection = cndb
.CommandType = adCmdtext
.CommandText = "SELECT * FROM ApplicantDetails WHERE NINumber = '" & strNINumber & "' OR UserName = '" & strUserName & "' OR UserPassword = '" & strUserPassword & "' OR EmailContact = '" & strEmailContact & "';"
End with

rscheckuser.Open cmdcheckuser,,adOpenStatic,adLockOptimistic

on error resume next

if err.number <> 0 then
response.write "error connecting to database<br>" &_
"Error: " & err.Description
response.end
end if

'if can't find a record with matching NINumber then user is not in db so submit their details
if rscheckuser.EOF = true or rscheckuser.BOF = true then

'pass values as parameters
With cmdaddtodatabase
.CommandTimeout = 15
set .ActiveConnection = cndb
.CommandType = adCmdText
.CommandText = "INSERT INTO ApplicantDetails (ContractedInIndicator .....This all works perfectly..passes parameters etc)


on error resume next
.Execute

if err.number <> 0 then
Response.write err.description
Response.End
end if

'if was successfully submitted then redirect to process page with NINumber
if err.number = 0 then
id = strNINumber 'added this line
Response.redirect "process.asp?id=" & Encrypt(strNINumber) 'added
'Response.redirect "process.asp?id=" & strNINumber
Response.End
end if

End with

elseif rscheckuser("NINumber") = strNINumber then

%>
<!-- if persons NINumber has been found in db then tell them they are already registered! -->

<table class="bylinefont" width="100%" bgcolor="white" border="0" cellpadding="0" cellspacing="0" align="left"> this says: you are already registered
</table>

<%elseif rscheckuser("UserName") = strUserName then%>

<table class="bylinefont" width="100%" bgcolor="white" border="0" cellpadding="0" cellspacing="0" align="left">This says please enter a different username </table>

<%elseif rscheckuser("UserPassword") = strUserPassword then
%>

<table class="bylinefont" width="100%" bgcolor="white" border="0" cellpadding="0" cellspacing="0" align="left">This says please enter a different password </table>

<%elseif rscheckuser("EmailContact") = strEmailContact then
%>

<table class="bylinefont" width="100%" bgcolor="white" border="0" cellpadding="0" cellspacing="0" align="left">This says that the email is already in use </table>

<%end if%>
<%end if%>

</body>
</html>

Reply With Quote
  #6  
Old November 6th, 2003, 04:16 AM
Pain Pain is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: Sheffield, UK
Posts: 94 Pain User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via ICQ to Pain
ok you need a correct example?



dim A, B, C
A = 10
B = "blue"
C = "<hr>"

If A <> 10 then
response.write ("I've not set A properly")
else
response.write("Condition A set properly")
end if

IF B = "blue" then
response.write("Condition B set properly")
else
response.write("Condition B incorrectly set")
endif

If B = "blue" and C = "10" then
response.write("Condition BC correctly set")
else
if A = 10 and B = "blue" then
response.write("Condition AB correctly set")
else
response.write("HELP! IM CONFUSED HERE! BLEEP GLEE WIBBLE *DROOL*")


Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > if - else if - else if - confused


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
Stay green...Green IT