Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Professional For advanced coder questions in ASP 3. 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 Professional 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 May 9th, 2013, 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 Detect if a names field exists in a record set

Hello classic ASP world, hopefully there are still a few of us around...

Does anybody know how to check if a named field is within a record set?

EG id, field1, field2, field3 have been selected. Is it possible for VBScript to detect if field2 has been selected..

Please assume I dont know, nor can see the actual SELECT. I need to detect this after the query has been executed.

How to do it while looping, BUT I am also hoping this is possible without looping

Code:
    sql = "SELECT * from tableName;"
    set rs = conn.execute(sql)
    For Each field in rs.Fields
      if field.Name = "lookinForFieldName" then foundField = true else foundField = false
    next
TYIA
__________________
Wind is your friend
Matt

Last edited by mat41; May 9th, 2013 at 10:36 PM..
 
Old May 10th, 2013, 03:35 AM
Imar's Avatar
Wrox Author
Points: 70,322, Level: 100
Points: 70,322, Level: 100 Points: 70,322, Level: 100 Points: 70,322, Level: 100
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Utrecht, Netherlands.
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
Default

Hi Matt,

The only way I know is by looping over the Fields collection as I've described here: http://imar.spaanjaars.com/262/find-...database-table

Imar
__________________
Imar Spaanjaars
http://Imar.Spaanjaars.Com
Follow me on Twitter

Author of Beginning ASP.NET 4.5 : in C# and VB, Beginning ASP.NET Web Pages with WebMatrix
and Beginning ASP.NET 4 : in C# and VB.
Did this post help you? Click the button below this post to show your appreciation!
 
Old May 13th, 2013, 12:04 AM
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

Hi Imar - Thank you for you time

My research/testing says its impossible without looping. For others there was an issue with my initial post. It was missing an exit for therefore would have always been false:

Code:
dim rs,field,foundField sql = "SELECT * from table;" set rs = conn.execute(sql) For Each field in rs.Fields    if field.Name = "someFieldName" then        foundField = true    exit for    else        foundField = false    end if next
__________________
Wind is your friend
Matt




Similar Threads
Thread Thread Starter Forum Replies Last Post
Populate form fields if record exists in table RobertIngles Access VBA 1 February 18th, 2011 05:21 AM
Checking to see if record exists EmmaGale Classic ASP Basics 6 March 14th, 2006 02:39 AM
How to detect if a table exists? mnoon Access 5 February 11th, 2005 09:43 AM
How to detect the record modified (ado) jolzy Pro VB Databases 3 October 28th, 2004 02:18 PM
Record Exists hugh@kmcnetwork.com SQL Language 3 September 13th, 2004 02:36 PM





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