Wrox Programmer Forums
|
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases 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 24th, 2003, 09:47 PM
Authorized User
 
Join Date: Jun 2003
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to tp194
Default Printing Recordsets from a query

I have a query that gets company name and address info from an access database.

I'm able to print the resultset on the page, but I have a formatting question:

There are two address columns in the database (address1 and address2). Not every company uses address2, so it's blank. When I use the code below, it prints the blank line for those vendors without anything in address2. Is there a way around this problem?

Thanks

Terry

While Not objRS.EOF


        Response.Write "<p>" & objRS("companyName") & "<br>"
        Response.Write objRS("address1") & "<br>"
        Response.Write objRS("address2") & "<br>"
        Response.Write objRS("city") & ", " & objRS("state") & " " & objRS("zip") & "</p>"
        objRS.MoveNext
    Wend
 
Old June 24th, 2003, 09:53 PM
Authorized User
 
Join Date: Jun 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

maybe something like this will work..

if objRS("address2") = " " Then
  ' Do nothing
else
  Response.Write objRS("address2") & "<br>"
End if

hope this helps :)
 
Old June 24th, 2003, 10:07 PM
Authorized User
 
Join Date: Jun 2003
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to tp194
Default

Yeah, I tried that, but it didn't work...I modified the code to look like this:

While Not objRS.EOF


        Response.Write "<p><b>" & objRS("companyName") & "</b><br>"
        Response.Write objRS("address1") & "<br>"
        if objRS("address2") = " " Then
            Response.Write objRS("city") & ", " & objRS("state") & " " & objRS("zip") & "</p>"
        else
              Response.Write objRS("address2") & "<br>"
            Response.Write objRS("city") & ", " & objRS("state") & " " & objRS("zip") & "</p>"
        End if

        objRS.MoveNext


It prints out the same though. Is that the right way to check if the recordset is empty?

Thanks for your reply.

t~
 
Old June 24th, 2003, 10:23 PM
Authorized User
 
Join Date: Jun 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

maybe instead of checking if objRS("address2") = " "
check if it is ""
the way u have at the moment.. checks if it is just a space
 
Old June 24th, 2003, 10:40 PM
Authorized User
 
Join Date: Jun 2003
Posts: 24
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to tp194
Default

Droopy

I was able to get the formatting right by using the IsNull function. I've posted the new code below...thanks for your help!

t~

While Not objRS.EOF


        Response.Write "<p><b>" & objRS("companyName") & "</b><br>"
        Response.Write objRS("address1") & "<br>"
        if IsNull(objRS("address2")) Then
            Response.Write objRS("city") & ", " & objRS("state") & " " & objRS("zip") & "</p>"
        else
              Response.Write objRS("address2") & "<br>"
            Response.Write objRS("city") & ", " & objRS("state") & " " & objRS("zip") & "</p>"
        End if

        objRS.MoveNext
    Wend
 
Old June 24th, 2003, 10:55 PM
Authorized User
 
Join Date: Jun 2003
Posts: 21
Thanks: 0
Thanked 0 Times in 0 Posts
Default

cool :)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Printing the Query srinivas16 Pro VB 6 0 July 24th, 2007 11:43 PM
UPDATE query after subscription printing rodanie Reporting Services 1 July 19th, 2006 01:44 PM
capturing printing settings when printing reports nikolaosk Access VBA 0 February 8th, 2005 04:14 AM
Need help with recordsets chacquard Access VBA 5 June 21st, 2004 11:58 PM
Recordsets bph Access VBA 17 February 17th, 2004 03:19 PM





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