Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

if statement 1

Status
Not open for further replies.

nonprogrammer

Technical User
Dec 28, 2005
143
US
hello

I am trying to put an if statement in one of my asp pages. That should redirect me to a link if the field is empty in the database. I tried the following code but it does not seem to work. any suggestions?

Code:
<%if Recordset1.Fields.Item("Pick").Value = "" then response.Redirect("[URL unfurl="true"]http://www.google.com")[/URL]   %>

[code]
 
Are you getting an error message, or just no redirect? You may be seeing either a NULL or a space in your recordset. You can try solving those 2 potential problems by using
Code:
<%if Trim(Recordset1("Pick") & "") = "" then response.Redirect("[URL unfurl="true"]http://www.google.com")[/URL]   %>
Adding an empty string will stop the NULL error and Trim will remove any spaces

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
johnwm,

do you have any idea why it might stop working?

I was working great and then all of the sudden it stopped
 
Looks like you either had a NULL or one or more spaces in the database instead of the empty string you were expecting. Make sure you validate the data going INTO the database!

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first.
'If we're supposed to work in Hex, why have we only got A fingers?'
Drive a Steam Roller
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top