Re: Referencing data column by it's name
- From: "Daniel Crichton" <msnews@xxxxxxxxxxxxxxxx>
- Date: Mon, 27 Nov 2006 08:33:05 -0000
nospam@xxxxxxxxx wrote on Sat, 25 Nov 2006 17:40:37 GMT:
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)
What nobody else spotted is that ADO uses a zero based field numbering
system, so the first column is actually rs(0), not rs(1).
Can't you reference it somehow by saying var_firstname = rs("FirstName")
or something like that?
Yes, that's exactly it, as already pointed out by other replies. Didn't you
try it before posting?
Dan
.
- Follow-Ups:
- Re: Referencing data column by it's name
- From: Bob Barrows [MVP]
- Re: Referencing data column by it's name
- References:
- Referencing data column by it's name
- From: nospam
- Referencing data column by it's name
- Prev by Date: Re: How to read binary data into a varchar(80) Dbase File
- Next by Date: Re: ADO in multithreaded: Application Verifier (with WinDbg) gives "Invalid Handle" at the end of my application
- Previous by thread: Re: Referencing data column by it's name
- Next by thread: Re: Referencing data column by it's name
- Index(es):