asp classic - Detect if a names field exists in a record set -


is possible check if named field within record set?

eg id, field1, field2, field3 have been selected. possible vbscript detect if field2 has been selected. hoping possible without looping

please assume dont know, nor can see actual select. need detect after query has been executed.

this how done using loop, hoping possible without looping:

dim rs,field,foundfield sql = "select * table;" set rs = conn.execute(sql) each field in rs.fields    if field.name = "somefieldname"        foundfield = true    exit    else        foundfield = false    end if next 

tyia

i use similar function (in vb6) 1 proposed bfavaretto... i'm curious why op says doesn't work?

public function fieldexists(byval rs recordset, byval fieldname string) boolean      on error goto merr      fieldexists = rs.fields(fieldname).name <> ""     exit function  merr:     fieldexists = false  end function 

this function works me... , doesn't return false negatives far know. also, appears faster executing loop fields included in collection; fields missing, execution times of both methods seems equivalent.


edit

for vbscript, above function this:

function fieldexists(byval rs, byval fieldname)       on error resume next     fieldexists = rs.fields(fieldname).name <> ""     if err <> 0 fieldexists = false     err.clear  end function 

and code posted in question like:

dim rs,field,foundfield sql = "select * table;" set rs = conn.execute(sql) foundfield = fieldexists(rs, "somefieldname") 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -