Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Please help... asp programming... If statement

Posted on 2005-03-14
7
Medium Priority
?
299 Views
Last Modified: 2010-04-17
How do I get the if statement to work. This program works:

<%
Response.Expires = -1000
Dim oRS, oConn,sSQL
Dim rndMax,rndNumber
Dim companydataID
companydataID = request.querystring ("id")
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("companydata.mdb"))
sSQL = "SELECT * FROM companydata WHERE acompany = '"&companydataID&"' "
Set oRS = Server.CreateObject("ADODB.Recordset")
oRS.Open sSQL , oConn, 3
rndMax = CInt(oRS.RecordCount)
oRS.MoveFirst
Randomize Timer
rndNumber = Int(RND * rndMax)
oRS.Move rndNumber
response.redirect oRS("alink")
set oRS = nothing
set oConn = nothing
%>

But this one doesn't...







<%
Response.Expires = -1000
Dim oRS, oConn,sSQL
Dim rndMax,rndNumber
Dim companydataID
companydataID = request.querystring ("id")

if (companydataID != null)

Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath("companydata.mdb"))
sSQL = "SELECT * FROM companydata WHERE acompany = '"&companydataID&"' "
Set oRS = Server.CreateObject("ADODB.Recordset")
oRS.Open sSQL , oConn, 3
rndMax = CInt(oRS.RecordCount)
oRS.MoveFirst
Randomize Timer
rndNumber = Int(RND * rndMax)
oRS.Move rndNumber
response.redirect oRS("alink")
set oRS = nothing
set oConn = nothing


end if
%>


Ultimately, I'm trying to use the same redirect page for 2 different parameters  id and company... Any suggestions would be greatly appreciated...
0
Comment
Question by:chkanuck
  • 3
  • 2
  • 2
7 Comments
 
LVL 3

Accepted Solution

by:
stu_pb earned 1000 total points
ID: 13537339
You need to have the keyword Then after your If statement.  Also an empty querystring will be an empty string ("").

if (companydataID != "") Then
.
.
.
end if

Good Luck!
0
 
LVL 9

Expert Comment

by:caball88
ID: 13537405
even with the keyword "then" i don't remember VBScript accepting "!=" as not equal. i am use to seeing it as "<>" instead.
0
 
LVL 3

Expert Comment

by:stu_pb
ID: 13537421
Oops! <> it is!
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:chkanuck
ID: 13537704
I wish I could accept both of your answers... Thank you very much.  It works perfectly!
0
 

Author Comment

by:chkanuck
ID: 13537711
I guess I'll have to just go with the first response.  Thank you both...
0
 
LVL 9

Expert Comment

by:caball88
ID: 13545561
you could have split the points...hehe its ok no big deal as long as you got your problem fixed.
0
 

Author Comment

by:chkanuck
ID: 13546214
Awe... sorry about that.  This was my second post.  Next time:)  Thanks again...
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
When you see single cell contains number and text, and you have to get any date out of it seems like cracking our heads.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Six Sigma Control Plans

564 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question