Wrox Programmer Forums
|
ASP Pro Code Clinic As of Oct 5, 2005, this forum is now locked. No posts have been deleted. Please use "Classic ASP Professional" at: http://p2p.wrox.com/forum.asp?FORUM_ID=56 for discussions similar to the old ASP Pro Code Clinic or one of the other many remaining ASP and ASP.NET forums here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP Pro Code Clinic section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old June 17th, 2003, 06:32 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default proper display

Hi all,

I want that If record not found in the table, it will display “ - “ sign on the page,
Some blank records are save in the table, in the blank field it will display (dask) sign
I am using following coding.


do while rs.eof=false
Response.Write("<tr>")
Response.Write("<td>" & rs("recordno") & "</td>")
Response.Write("<td>" & rs("description") & "</td>")
Response.Write("<td>" & rs("category") & "</td>")
Response.Write("<tr>")
rs.movenext
loop

best regards.

Mateen Martin
[email protected]
 
Old June 17th, 2003, 06:46 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 231
Thanks: 0
Thanked 0 Times in 0 Posts
Default

If the record does not exist then it will never be displayed. Your code is looping through the table one record at a time. It will never get to a record that does not exist.

If you are talking about Null or blank fields in the record then you will need to place the field into a variable and test whether it has a value or not. For example:

Code:
Dim fieldData

do while rs.eof=false 
Response.Write("<tr>")

fieldData = rs("recordno") & ""
If Len(fieldData) = 0 Then fieldData = " - "
Response.Write("<td>" & fieldData & "</td>")

fieldData = rs("description") & ""
If Len(fieldData) = 0 Then fieldData = " - "
Response.Write("<td>" & fieldData & "</td>")

fieldData = rs("category") & ""
If Len(fieldData) = 0 Then fieldData = " - "
Response.Write("<td>" & fieldData & "</td>")

Response.Write("<tr>")
rs.movenext
loop
Regards
Owain Williams
 
Old June 18th, 2003, 01:25 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 518
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Dear Owain Williams

Thanks for your response.
it is solve my problem.
now page is display proper way.

best regards.

Mateen Martin



Quote:
quote:Originally posted by owain
 If the record does not exist then it will never be displayed. Your code is looping through the table one record at a time. It will never get to a record that does not exist.

If you are talking about Null or blank fields in the record then you will need to place the field into a variable and test whether it has a value or not. For example:

Code:
Dim fieldData

do while rs.eof=false 
Response.Write("<tr>")

fieldData = rs("recordno") & ""
If Len(fieldData) = 0 Then fieldData = " - "
Response.Write("<td>" & fieldData & "</td>")

fieldData = rs("description") & ""
If Len(fieldData) = 0 Then fieldData = " - "
Response.Write("<td>" & fieldData & "</td>")

fieldData = rs("category") & ""
If Len(fieldData) = 0 Then fieldData = " - "
Response.Write("<td>" & fieldData & "</td>")

Response.Write("<tr>")
rs.movenext
loop
Regards
Owain Williams





Similar Threads
Thread Thread Starter Forum Replies Last Post
ExecuteNonQuery not giving proper result Lalit Pradhan ASP.NET 2.0 Professional 6 July 24th, 2008 02:00 AM
Proper use of Arbiters scott.nortman BOOK: Professional Microsoft Robotics Studio ISBN: 978-0-470-14107-6 1 June 23rd, 2008 08:06 PM
tell me the proper free book name naveed77 Beginning VB 6 1 January 6th, 2007 11:31 AM
Proper Case IN Xsl Israr XSLT 8 April 4th, 2006 01:39 PM
I need a proper stepwise J2EE tutorial sherbir J2EE 2 July 30th, 2004 12:52 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.