Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

basic ASP question

Status
Not open for further replies.

thelearner

Programmer
Jan 10, 2004
153
US
Hi,

<%=rstEmployee("City")%>
In the above string, why do we need to put "" around CITY, what's the rule?

*CITY is a field name from the table

Thanks
 
You need to put "" around the database field. If you do not do so, the code will think you are passing in a variable. The column name from the records set is not a predefied asp object or one that you are defining. So you need to put the "" around any column name you call when requesting data from the database.

Hope the answers the questions.
 
also an RS object is actually an array, you can return values via rs(0), rs(1), etc by handing it "city" you're causing this special array to search it's headers for "city" and it's doing the conversion of "city" to say 5 for you. now this text value enables it to search for it because it's not an integer, if you pass it a variable, then it will try to resolve the variable value down to an integer either by searching it's headers, or if the variable is an integer, translating this to the value in that slot. otherwise if it fails on both accounts, then it'll return you them spiffy errors we see often :)

also the description i gave i know is not 100% on target, but for mere explaination's sake should cover your bases pretty good.
 
So, because CITY is not a variable name but a field name. But in another string,
strClient=Ucase(request("clientcode"))
CLIENTCODE is a variable name, why do we need "" now?

very confusing!

Thanks in advance.

 
though both issues look different are exactly the same.
In both cases you are finding the value of an item in a collection (array of values) and using the name as the identifying index.

or to put it another way, the collection is an associative array and you are using the name to access the value.



Chris.

Indifference will be the downfall of mankind, but who cares?
 
<quote>
So, because CITY is not a variable name but a field name. But in another string,
strClient=Ucase(request("clientcode"))
CLIENTCODE is a variable name, why do we need "" now?
</quote>

actually in the instance you gave as an example, it's a string, and that string is then used as an argument/parameter for the item collection.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top