If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Data Access, Manipulation & Batch Languages > ASP > If statement Not Working

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 02-03-04, 10:43
JimWa JimWa is offline
Registered User
 
Join Date: Jan 2004
Posts: 40
If statement Not Working

After a recent switch from MS Access to SQL Server 2000 some simple ASP if statements seem to not work.

In MS Assess I would use this an if statement to determine if a field was null.

<% if objRS("Review") <> "" then %>

Now this doesn't work to evelauate the field in SQL Server 2000 for null. I work with allot of text and it seems redundant for me to put triggers into the databases that will have to be maintained and updated when a text fields is empty or not.

Anyone with experience in this or who knows how to work with if statements, ASP when dealing with SQL Server 2000 would be greatly appreciated.

Thanks,

JimWa
Reply With Quote
  #2 (permalink)  
Old 02-03-04, 11:11
gyuan gyuan is offline
Registered User
 
Join Date: Dec 2003
Posts: 454
In MSSQL, you need to use

<% if Not IsNull(objRS("Review")) then %>
Reply With Quote
  #3 (permalink)  
Old 02-03-04, 12:55
JimWa JimWa is offline
Registered User
 
Join Date: Jan 2004
Posts: 40
Thats seems to have done the trick. Thank you so much for your help!

You wouldn't happen to know why working with Double quotes " is an issue with SQL Server do you?
Reply With Quote
  #4 (permalink)  
Old 02-03-04, 13:19
gyuan gyuan is offline
Registered User
 
Join Date: Dec 2003
Posts: 454
<% if objRS("Review") <> "" then %> is used to check if the field is blank.
Reply With Quote
  #5 (permalink)  
Old 02-03-04, 13:33
JimWa JimWa is offline
Registered User
 
Join Date: Jan 2004
Posts: 40
Yes that works in MS Access as the backend... And what I use currently. Am testing my new database (MS Sequel Server 2000) and it does not work.

And I tested the wrong thing early. Your example didn't work as I had previoulsy thought it did.

It's like it can't recongnize blank text fields or something.
Reply With Quote
  #6 (permalink)  
Old 02-03-04, 13:48
gyuan gyuan is offline
Registered User
 
Join Date: Dec 2003
Posts: 454
If you think that the value of the field may be NULL or empty, it is better to use the following statement:

<%
If Not IsNull(RS("columnName")) And Not IsEmpty(RS("columnName")) Then
%>
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On