SSG wrote:
In my database table ,
When asking a database-related question, even if you do not think it is
relevant you should always supply the type and version of the database you
are using. It is relevant more often tha nis commonly realized.
I have field to store the text,..
I am tryinf to find the length of the filed in ASP like below
response.write len(rs("cname1"))
It is displaying the value , when the data in the field is nonzero, it
is not displaying anything if the filed is mty in table..
Do you have error-trapping (on error resume next) enabled? If so, disable it
and see if your code is generating an "invalid use of Null" error. That
should be a clue to your problem. If your field is configured to accept
Null, then you are seeing the difference between Null and a zero-length
string.
You _could_ test the field for Null before attempting to get its length:
val = rs("cname1").value
if not isnull(val) then
response.write len(val)
else
response.write "0"
end if
But my preferred solution would be to modify the sql statement generating
the recordset to ensure than the field never contains Null. The details
about how to do this depend on what database type and version you are using
.... see? it is relevant even in this case!
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"