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 wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Nested variables in asp

Status
Not open for further replies.

Edcrosbys

ISP
Apr 26, 1999
112
US
I'm not sure if what I'm trying can be done. I have the following situation:

variables:

sql_jobid
sql_description
....etc

where jobid, description, etc are fields from my database.

I would like to call these variables into an if, then reading the second part of the variable from the database so I don't have to type out the same thing 40 times... Here's a snippet of what I'm trying (who knows if the syntax is right though):


sql = "select * from jobs where"
first = "true"
for each x in rs.fields
if first = "true" then
sql = sql sql_(x.name) <----- Here's one place I'm
trying it.
first = &quot;false&quot;
else
sql = sql sql_(x.name)
end if
next
sql = sql &quot;;&quot;
rs.open sql,conn

Thanks Alot!!!
Eric
 
You can't do what you are thinking there.
But perhaps this example might be useful to you. Using the ASP function getrows(), the contents of a record set can be returned into an array Here in this example, each row gets referred to as i. The columns in the recordset are the elements of the array, and here I refer to them as 0 and 1. My FOR loop processes each row, but you could write a loop that processes each column of the current row, from 0 to n.
-------------------
Sub readTasks()
Set rs2 = Server.CreateObject(&quot;ADODB.Recordset&quot;)
sql = &quot;Select TaskId, TaskDesc from Tasks&quot;
rs2.Open sql, conn, 0, 1, 4

alldata = rs2.getrows ' put the record set into array
numrows = ubound(alldata,2) ' get upper limit of array
For i = 0 to numrows
Response.write(alldata(0,i) & &quot; &quot; & alldata(1,i))
Next
End Sub
----------------------------
Maybe this gives you something to think about.
bp

 
Wow,

Hmm... Thanks alot bp! I definatly have something to do now today. I really appreciate the push in the right direction!

Thanks Alot!
edcros
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top