473,408 Members | 2,813 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Find length of field from database table

SSG
In my database table , 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..

I cant understand y it is displaying the length as 0 , bcaz i want to
compare the length , if the length is zero , it will display one result
or else it will display the value....

Jan 25 '07 #1
2 3860
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"
Jan 25 '07 #2
"SSG" <ss****@gmail.comwrote in message
news:11**********************@q2g2000cwa.googlegro ups.com...
In my database table , 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..

I cant understand y it is displaying the length as 0 , bcaz i want to
compare the length , if the length is zero , it will display one result
or else it will display the value....
Perhaps...

if rs("cname1") = "" then
Response.Write "Empty"
else
Response.Write rs("cname")
end if

--
Roland Hall
Feb 2 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Marco Simone | last post by:
Hi, What is your opinion about using Lookup field in table. I would like to use lookup field in table 1, so that I can choose data in combo box from table 2. Is this good design of database? ...
0
by: Bennett Haselton | last post by:
It seems whenever I add a new field to a database table that's queried by DataAdapters in my project, I get run-time errors because I don't go back and re-generate all the DataAdapters to read the...
8
by: David | last post by:
Hi, Could someone please xplain how to add a field to an existing SQL table in VB.Net I have added the field in the Server Explorer and it shows up when I reload the program but I cannot...
1
by: Dan Manes | last post by:
Wondering what other people do about this issue... You're writing a web app in asp.net that requires user input. Data will be stored in SQL Server Express database. You want to make sure data...
1
by: hazz | last post by:
What do I do to capture the checkbox values as listed below in order to update the database table. There will be an ID field also contained in the row to use in the update query. What would I put...
2
by: narpet | last post by:
Hello all, I'm still learning about c# and I have a major function that I need to write (in a forms application), and I have no idea how to go about it. Here's the scenario: I have a text file...
4
by: Amar | last post by:
Hi All, I need to select data from a database table containing huge amount of data. Now I am storing data using one primary key and I am just using simple select statement, and this process...
0
by: OldStd | last post by:
Updating data using 2 data sets I am having some problems in updating the database using two datasets as suggested by someone. 1. Data is displayed in a data grid from a dataset generated using...
1
by: ayyanki | last post by:
Hello all, I'm still learning about c# and I have a major function that I need to write (in a forms application), and I have no idea how to go about it. Here's the scenario: I have a text file...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.