 |
| 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
|
|
|
|

October 16th, 2003, 09:05 AM
|
|
Authorized User
|
|
Join Date: Sep 2003
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
news database
I want to display news records returned from a access database on a web page. How can I restrict the query where always " top 6 records are displayed".
the fields in my database are id,title,headlines,date_posted .
Please help.
|
|

October 16th, 2003, 02:13 PM
|
|
Authorized User
|
|
Join Date: Jul 2003
Posts: 41
Thanks: 0
Thanked 1 Time in 1 Post
|
|
Create a hidden EntryDate field in order to later sort your queries to the DB.
Then do a decrement "for" loop counting down from 6...placing the articles on your page until the loop quits.
|
|

October 16th, 2003, 02:36 PM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 702
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Please provide table structure and I will be happy to help.
Sal
|
|

October 17th, 2003, 06:27 AM
|
|
Registered User
|
|
Join Date: Oct 2003
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
******* Connection *******
******* Execute Sql Query *******
Dim i
i = 1
Rs.MoveFirst
For i = 1 to 6
Rs.Fields ("News")
Rs.Fields ("Details")
Rs.Movenext
Next
If you could post details, I can help you with re-writing code ...
Best Regards
Burak Balibey
|
|

October 17th, 2003, 08:42 AM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 702
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Provide the following if you are still interested,
-Database being used and version (Access 2000, 2002, SQL Server 2000, 7)
-Table Structure (table name, and field names)
There is a way to query the database and get exactly 6 records back.
If Access is your front end
Sample code
SELECT TOP 6 YourTable1.FieldToReturn
FROM YourTable1
ORDER BY YourTable1.FieldToReturn DESC;
If you want the bottom, sort ASC
Sal
|
|

October 17th, 2003, 12:00 PM
|
|
Authorized User
|
|
Join Date: Sep 2003
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Thanks sal,
Table name : news
Fields : id (Autonumber) , Headline(text), news_story(text), date_posted(date)
Database : Access 2002
I want to run a asp code that returns exaclty top 6 headlines from the database .
I will appreciate your help.
|
|

October 17th, 2003, 01:34 PM
|
|
Friend of Wrox
|
|
Join Date: Oct 2003
Posts: 702
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
SELECT TOP 5 news.*
FROM news
ORDER BY news.id DESC;
I suppose you want the latest six.
there is no need for a loop inside your code.
Sal
|
Similar Threads
|
| Thread |
Thread Starter |
Forum |
Replies |
Last Post |
| Separating news from the articles and add news pic |
Isaak |
BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 |
1 |
December 12th, 2006 11:25 AM |
| News Ticker |
dangerduck |
BOOK: Professional Ajax ISBN: 978-0-471-77778-6 |
8 |
April 21st, 2006 07:09 AM |
| news ticker |
badgolfer |
ASP.NET 1.0 and 1.1 Basics |
0 |
October 13th, 2004 03:34 AM |
| news tool |
alitoday |
Javascript |
3 |
July 15th, 2004 03:57 AM |
| News database |
gtmm9 |
Access ASP |
0 |
October 9th, 2003 12:52 PM |
|
 |