Ask a Question related to ASP Database, Design and Development.
-
Lee Farrant #1
RS(fieldname) error when using column alias.
Could someone tell me why I cannot seem to reference a field in a
record set which I have given an alias to. I have given the field
c.firstname an alias of firstname but my RS function cannot find it
(it errors with undefines name etc). Is there something different
about referencing an alias to a field or something different when
joining table with a prefix eg: c.firstname. Code is below.
Thanks
Lee
Call OPEN_DB()
SQL = "SELECT p.profileid as profileid ,c.firstname as firstname
,c.lastname as lastname FROM customers c, profiles p WHERE p.profileid
= " & profileid & " and c.customerid = p.customerid;"
Set RS = MyConn.Execute(SQL)
firstname = RS(firstname)
RS.Close
Lee Farrant Guest
-
#33809 [Com]: pg_fetch_result: table alias produces invalid column result error
ID: 33809 Comment by: alan8 at maths dot topology dot org Reported By: torpedo51 at yahoo dot com Status: No... -
Given fieldname could not be found in the table.
Another newbie question here. I am trying to update one table ("Table A") and insert into another table ("Table B"): <cfquery DATASOURCE="tech... -
column alias help
per the CFMX7 livedocs: One way to create an alias is to concatenate (append) two or more columns to generate a value. For example, you can... -
dbase: how to get fieldNAME ofa table
Hello, below you will find a simple script that reads out info of a dbase It reads out all the records and every field of the record. For my... -
Bob Barrows #2
Re: RS(fieldname) error when using column alias.
Lee Farrant wrote:
There are two ways to reference an item in the Fields collection:> Could someone tell me why I cannot seem to reference a field in a
> record set which I have given an alias to. I have given the field
> c.firstname an alias of firstname but my RS function cannot find it
> (it errors with undefines name etc). Is there something different
> about referencing an alias to a field or something different when
> joining table with a prefix eg: c.firstname. Code is below.
>
> Thanks
> Lee
>
>
> Call OPEN_DB()
>
> SQL = "SELECT p.profileid as profileid ,c.firstname as firstname
> ,c.lastname as lastname FROM customers c, profiles p WHERE p.profileid
> = " & profileid & " and c.customerid = p.customerid;"
>
> Set RS = MyConn.Execute(SQL)
>
> firstname = RS(firstname)
>
> RS.Close
1. By using its zero-based index, or by using a variable/constant containing
that index. This is the most efficient way of referring to an item in a
collection.
So, to get the second field object you can do this:
rs(1)
or use a constant like this (you could also Dim a variable instead of using
a constant, but using the constant is more efficient):
const secondfield=1
rs(secondfield)
2. By using the name of the field, or a variable containing the name of the
field. To get the value of the field named thisfield, you can either use a
literal string like this:
rs("thisfield")
or use a constant like this:
const fieldname="thisfield"
rs(fieldname)
Bottom line: put quotes around the word "firstname" so that vbscript does
not think you are using a variable/constant.
HTH,
Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Bob Barrows Guest
-
Lee Farrant #3
Re: RS(fieldname) error when using column alias.
thanks,
Lee
*** Sent via Developersdex [url]http://www.developersdex.com[/url] ***
Don't just participate in USENET...get rewarded for it!
Lee Farrant Guest



Reply With Quote

