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!

Associative Array (Scripting.Dictionary) proglem... 1

Status
Not open for further replies.

RISTMO

Programmer
Nov 16, 2001
1,259
US
Hey,

This script is supposed to pull all the field names from a table and make an associate array with those set to "test".

Code:
<%@ LANGUAGE="VBSCRIPT" %>
<!-- #INCLUDE file="testADO.asp"-->
<%
Dim theFieldNames, theOtherFields
Set theotherFields=Server.CreateObject("Scripting.Dictionary")
Set theFieldNames = theConn.Execute("select * from INFORMATION_SCHEMA.columns where TABLE_NAME = 'testTable'")
Do While Not theFieldNames.EOF
	%><%= theFieldNames("COLUMN_NAME") %><br><%
	theOtherFields.Add theFieldNames("COLUMN_NAME"),"test"
	theFieldNames.moveNext
Loop
Response.Write("AID: " & theOtherFields.Item("AID") + "<br>")
%>

As you can tell, it doesn't run, because the key is set to --> theFieldNames("COLUMN_NAME") <-- instead of theFieldNames("COLUMN_NAME")'s value. I tried wrapping it in Eval, and that didn't work either. Help?

Thanks,
Rick

RISTMO Designs: Rockwall Web Design
Arab Church: Arabic Christian Resources
Genuine Autos: Kaufman Chevrolet & Pontiac Dealer
Rick Morgan's Official Website
 
This is one of VB(Script) default property/dererefencing weirdos... you actually assigned ADODB.Field as a dictionary key. Use this:
Code:
theOtherFields.Add theFieldNames("COLUMN_NAME")[b].value[/b],"test"

------
"There's a man... He's bald and wears a short-sleeved shirt, and somehow he's very important to me. I think his name is Homer."
(Jack O'Neill, Stargate)
[banghead]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top