Domanda

It's been years since I don't work with classic asp, and I can't remember how to do this.

I am looping trough my session variables to print them in a textbox, but when it hit a recordset variable it returns me an error.

    Dim Item    
    Dim sessao

    For Each Item in Session.Contents
        If Item <> "Servidor" AND Not IsNull(Session.Contents(item)) THEN
            response.write(Session.Contents(item))
            response.write(item + "<br/>")
            'sessao = sessao + (Item + "&" + Session.Contents(item) + "@")
        end if
    next

So I need something like if Item <> recordset then to skip this situation

È stato utile?

Soluzione

Session values that contain objects will always cause an error if you try to Response.Write them to the page.

You can avoid this by checking whether the Session value contains an object using IsObject() function.

In your code something like

If Item <> "Servidor" And Not IsObject(Session.Contents(item)) Then

IMPORTANT:

As meda points out it is expensive to store ADODB.Recordset objects inside session values. It's not recommended to do this if you can explain what it is you are trying to accomplish we might be able to provide a more viable solution.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top