VBscript

  • I know this isn't the right msgboard to post this msg, but people tend to be very helpful here!

    I have a problem with the following:

    <%

    output.MoveFirst()

    While NOT output.EOF

    qfields.MoveFirst()

    While NOT qfields.EOF%>

    <TD><%=output("qfields("name")")%></TD>

    <%qfields.MoveNext()

    Wend%>

    </tr>

    <%

    output.MoveNext()

    Wend%>

    Basically I need to cycle through a recordset (output) pulling out data.  The problem is the fields that I want to pull out are specified within another recordset (qfields).

    And example being:

    qfields recordset

    id      name

    1       st_date

    2       st_gross

    I want to cycle through the output recordset and pull out the st_date and st_gross fields.

    Hopefully somebody can point me in the right direction.

    Thanks!

    James Knight

     

  • It's hard to point you in the right direction because the browser is removing some of your code.

    However can I assume that you have 2 recordsets opened and that you are filtering the second record set depending of the value in the first one to allow you to display some sort of web based report??

    If it's the case then maybe you can simple change the select from the first query and make an ?er join on the other table so you don't have to worry about matching rows manually.

  • From my understanding :

    -first recordset specifies wich comlumn to show from the sec one ?(first recordset 1 row specifying the columns)

    -secodn recordset contains the recordset with your result that YOU want to filter by COLUMNS.

    If my understanding is correct than what you need is:

    FILTER the result on SERVER using CASE

    Ex StoredProc:

    ....

    Select @varcol1=col, @varcol2=col2...FROM FirstTable WHERE....

    Select

    case when @varcol1=... then TableValue(As String) else EmptyString end+

    case when @varcol2=... then TableValue(As String) else EmptyString end+

    ...

    From SecondTable

     

    This way you will get your result as a RecordSet of 1 FormattedColumn

    If this doesn't work for you (1 formatted column) than you can try use DynamicSQL

    instead of doing NETWORK traffic by retrieving a result that you are using partially.

     

    If you wanna go with your solution than should be smthing like this

    for ii=0 to (NoOfCols in qfields)

           Var=qfields(ii)    

            <TD><%=output(var)%></TD>

    next ii

     


    Kindest Regards,

    Vasc

  • Thanks for all your help.  I found out that the reason it wasn't working was that I needed to trim the output of the qfields recordset!

    Now that it's all working fine, I need to try and output the recordset into an array so I can sort without having to requery the database.  This may sound as if I asking people to do all the work for me, but I can assure you I've been on this case for some time!  So if anybody can point my in the right direction for dumping recordset data into an array and displaying the array, it would be most appreciated! 

     

    Many thanks,

     

    James Knight

  • Hi James

    did a quick search for vbscripts and array and found the following information which might help you.

    Also isnt the recordset a sort of array anyway ?

    http://www.winguides.com/scripting/reference.php?id=1

    Finally wouldnt sorting the data before it hits the recordset be good?

    I may not understand what you are asking either.

    Let us know how you go.


    ------------------------------
    Life is far too important to be taken seriously

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply