?
Solved

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

Posted on 2005-03-14
7
Medium Priority
?
290 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 

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

Get real performance insights from real users

Key features:
- Total Pages Views and Load times
- Top Pages Viewed and Load Times
- Real Time Site Page Build Performance
- Users’ Browser and Platform Performance
- Geographic User Breakdown
- And more

Question has a verified solution.

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

Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
Starting up a Project
Suggested Courses

770 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