using a variabe to reference recordset object

Results 1 to 2 of 2

Thread: using a variabe to reference recordset object

  1. #1
    Kate Guest

    Default using a variabe to reference recordset object

    here&#039;s what I think I&#039;m trying to do ... <BR><BR>objRSTheseColumns contains 6 names which are to be used as column headers in a table on my asp page.<BR><BR>objRSData contains 10 rows of data, each row having 20 fields only 6 of which I want to display - that is, the 6 as defined by the names in objRSTheseColumns<BR><BR>so, I loop about, movenexting about in the two recordset objects, but I can&#039;t use the current value of objRSTheseColumns to reference the field in objRSData. I want to write something like ...<BR><BR>aVariable = objRSTheseColumns("Name")<BR>...<BR>Response.Write "&#060;TD class = &#039;expandcell&#039;&#062;" & objRSData(aVariable)<BR><BR>but this doesn&#039;t work. I don&#039;t want to hardcode the fields required from objRSData at this point because the end-user can change them.<BR><BR>Hope this makes sense,<BR><BR>Thankyou<BR><BR>Kate<BR><BR>

  2. #2
    Join Date
    Dec 1969

    Default RE: using a variabe to reference recordset object

    It would help if we could see how you are getting your recordsets. However here is a thought that might work. you have objRSColumnNames which contains 6 values. Loop through the RS and get the values writing a string like this:<BR>"Col1, Col2, Col3, Col4, Col5, Col6" and name that sring strSelectFields. Create your objRSData with the follwoing SQL statement:<BR>"Select "+strSelectFields+" From (Table Name) Where (Conditions)"

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts