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 February 24th, 2006, 09:27 PM
Authorized User
Join Date: Nov 2005
Posts: 51
Thanks: 0
Thanked 0 Times in 0 Posts
Default Get Field Names

Is there a way to get all field names in a table without returning an entire recordset? This works, but it returns everything which is probably unneccessary:
Dim sSQL
Dim Field
Dim oRS
sSQL = "SELECT * FROM table"
Set oRS=Server.CreateObject("ADODB.RecordSet")
oRS.Open sSQL, "DSN=dbname"

For Each Field in oRS.Fields
Response.Write Field.Name
Old February 25th, 2006, 05:06 AM
Imar's Avatar
Wrox Author
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts

Hi there,

You can add a WHERE clause that returns no records:

sSQL = "SELECT * FROM table WHERE SomeColum = 'Some Condition that is never true'"

That way, you still get the meta data but not the records....

Imar Spaanjaars
Everyone is unique, except for me.

Similar Threads
Thread Thread Starter Forum Replies Last Post
XSLT For Each - Field Names lahatfield XSLT 6 May 15th, 2007 06:33 AM
Error getting field names from query vbark Access VBA 1 January 23rd, 2007 09:04 PM
Replacing field names in datasheet philiprodley Access VBA 1 August 10th, 2006 12:47 PM
Retrieving Field Names RayRedSox Classic ASP Basics 0 October 12th, 2005 02:16 PM
Retrieving Dynamic Field Names tdaustin Classic ASP Basics 4 January 12th, 2004 11:10 AM

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