p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 24th, 2006, 09:27 PM
Authorized User
Points: 229, Level: 4
Points: 229, Level: 4 Points: 229, Level: 4 Points: 229, Level: 4
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Nov 2005
Location: , , .
Posts: 48
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
Next
%>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old February 25th, 2006, 05:06 AM
Imar's Avatar
Wrox Author
Points: 33,170, Level: 79
Points: 33,170, Level: 79 Points: 33,170, Level: 79 Points: 33,170, Level: 79
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 10,161
Thanks: 7
Thanked 188 Times in 186 Posts
Default

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
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
XSLT For Each - Field Names lahatfield XSLT 6 May 15th, 2007 07: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 01:47 PM
Retrieving Field Names RayRedSox Classic ASP Basics 0 October 12th, 2005 03:16 PM
Retrieving Dynamic Field Names tdaustin Classic ASP Basics 4 January 12th, 2004 11:10 AM



All times are GMT -4. The time now is 09:51 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc