Wrox Programmer Forums
Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Basics
| Search | Today's Posts | Mark Forums Read
Classic ASP Basics For beginner programmers starting with "classic" ASP 3, pre-".NET." 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 Basics 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 November 17th, 2016, 07:18 PM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2016
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Wink How do I display two entries under separate fields?

I need to display data from two separate fields in a .mdb file, and I can't envision how this is done. I'd like it to display the data like this:
https://i.stack.imgur.com/rk5Xa.jpg


I set my access database like this:
https://s16.postimg.org/o8nmjucph/411_a.jpg


I've already created a page for this and plugged in some of the info, but I can't figure out how to display multiple fields.

I thought this would work:

Code:
<% do until myResults.EOF %>
               <tr>
                 <td><% response.write myResults.Fields.Item("categories").Value %></td>
                 <td><% response.write myResults.Fields.Item("salary").Value %></td>
                 <td><% response.write myResults.Fields.Item("respondents").Value %></td>
               </tr>
               <% myResults.MoveNext
               loop %>
...but this shows all of the information in the database. For this example I just need the ones under "byBusinessSector" to show in this table.

I think I may have built the database wrong. Can .asp pages only read one data cell at a time? I'm not sure. Help!
 
Old November 17th, 2016, 10:22 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

its all about the query, this is the bit that you have not shown us. Yes it very likely that I would have built the database different. e.g There is a very good chance I would have normalized section and categories....anyhow to work with what you have I would:

At the moment association is the only category that is related to byBusinessSector, you need to update the section values for records 2-6 to create this relationship, the you may conditionally select based on this

Code:
 
'update the table so you can use the where clause in the select below
sql = "UPDATE allTitles set section='byBusinessSector' where ID < 7;"
myConnection.Execute(sql)

'now after executing the above update just select certain records 
sql = "SELECT categories, salary, respondents from allTitles where section = 'byBusinessSector';"
set myResults = myConnection.Execute(sql)
<% if not myResults.eof then
       do until myResults.EOF %>
           <tr>
            <td><%= trim(myResults("categories")) %></td>
            <td><%= trim(myResults("salary")) %></td>
            <td><%= trim(myResults("respondents")) %></td>
            </tr>
<%          myResults.MoveNext
        loop 
   else
       response.write "No records found"
   end if %>
__________________
Wind is your friend
Matt

Last edited by mat41; November 21st, 2016 at 05:28 PM..
 
Old November 21st, 2016, 05:19 PM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2016
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Sorry! That would help.

I have it as:
Code:
Set myResults = myConnection.Execute("SELECT * FROM allTitles")
As you may have guessed, I know very little about classic asp!
 
Old November 21st, 2016, 05:31 PM
Friend of Wrox
Points: 6,664, Level: 34
Points: 6,664, Level: 34 Points: 6,664, Level: 34 Points: 6,664, Level: 34
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jan 2004
Location: Sydney, NSW, Australia.
Posts: 1,870
Thanks: 12
Thanked 20 Times in 20 Posts
Send a message via AIM to mat41
Default

I am surprised that you could not take what I gave you and use it. Which part of my response do you not understand?

Now that I can see your connection object and the table name I have edited my post above. It should simply be copy/paste and the run. After you run it check that the UPDATE statement has fired, if so remove it from your code.
__________________
Wind is your friend
Matt




Similar Threads
Thread Thread Starter Forum Replies Last Post
how to display 2 fields as a choice in 1 combobox dilipv General .NET 0 March 5th, 2008 07:21 AM
Display 2 fields as one line in the combobox osemollie VB Databases Basics 2 May 17th, 2006 10:22 AM
Search and display fields in XML file kts_33 XML 5 September 28th, 2004 08:17 AM
Datagrid with Hyperlink display more fields in pg vnasibi ASP.NET 1.x and 2.0 Application Design 1 September 28th, 2004 03:58 AM
Search and display fields in XML file kts_33 Classic ASP XML 1 September 22nd, 2004 05:16 AM





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