Re: Referencing data column by it's name



It's more efficient to query only the columns you need instead of using *

select fieldname1, fieldname2 from myTable

var_firstname = rs!fieldname1

--

Regards,

Dave Patrick ....Please no email replies - reply in newsgroup.
Microsoft Certified Professional
Microsoft MVP [Windows]
http://www.microsoft.com/protect

<nospam@xxxxxxxxx> wrote:
here's my code:

<%

set conn = server.createobject("ADODB.Connection")
conn.open "databasename"

set rs = conn.execute("select * from myTable")

var_firstname = rs(1)

// THE NAME OF COLUMN 1 IS FirstName

%>

here's my question:
I'd like to know how to pull data from the database using the name of the
column instead of using it's column number rs(1)

Can't you reference it somehow by saying var_firstname = rs("FirstName") or
something like that?

Thanks for any input!
Michael

.



Relevant Pages

  • Re: Referencing data column by its name
    ... Dave Patrick wrote: ... select fieldname1, fieldname2 from myTable ... Actually, given the query you suggested, nothing beats: ... This email account is my spam trap so I ...
    (microsoft.public.data.ado)
  • Re: Form not showing correct record order
    ... Cynd wrote: ... Use a query for the subform instead of the table and sort that query as desired. ... ORDER BY FieldName1, FieldName2, etc... ...
    (microsoft.public.access.forms)