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!

seeing if a field is empty 1

Status
Not open for further replies.

derwent

Programmer
May 5, 2004
428
GB
I need to look at a row in a DB, if it is null they need to fill it in

Code:
if trim(rs("thisfield")) = null then
response.write "you need to fill in this field"
end if

I have also tried if rs("thisfield") = "" then

but nothing is output. If I use 'if NOT rs("thisfield") = "" then response.write' on a row with data the response.write is printed so it is reading the row.

Am I having early morning stupidities?
 
I think this will solve your problem.

Code:
If IsNull(RS("thisfield")) Then
  Response.Write "you need to fill in this field"
End If

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
A database field could have either a NULL or a zero length string.

However if your ASP "requires" a value for this field, Neither Null nor the empty string may be acceptable.

Here is an easy way to test for both conditions at the same time:
Code:
If RS("thisfield") & "" = "" Then
  Response.Write "you need to fill in this field"
End If

That code works because when you combine Null with an empty string, the result is an empty string.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top