How to populate a Recordset with another Recordset as a clause

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • GeryLuz
    New Member
    • Jul 2007
    • 4

    How to populate a Recordset with another Recordset as a clause

    Hi!

    I can't find how to build an SQL statement inside an ASP page using another open recordset as its where clause.

    My code is the following:

    Set rs0 = cn.Execute ("Select Id_Fam from Familia where Descripcion = '"&perfil&"' ")

    sql = "Select Id_Usuario from Usu_Fam where Id_Fam = " & rs0("Id_Fam")
    set rs2 = cn.Execute(sql)

    sqo = "Select Nombre_Usuario, Nombre, Apellido, Telefono, Localidad, [E-Mail], Fecha from Usuarios where id = " & rs2("Id_Usuario ")
    Set rs1 = cn.Execute (sqo)

    I've tried with lots of combinations of "" and '' and && and it never worked.

    Please help me!
    Thanks very much!!!
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    Is the first one working OK? can you say:[code=asp]response.write rs0("Id_Fam")[/code]?

    Jared

    Comment

    • edurran
      New Member
      • Jul 2007
      • 2

      #3
      Make Sure there is a record with Description exactly equal to Perfil. Otherwise the second call will have a blank string as a parameter.

      But as already suggested. Check that your first call is actually returning what you think it is.

      Comment

      • GeryLuz
        New Member
        • Jul 2007
        • 4

        #4
        Thank you very much Guys!
        The problem was there. I was requesting in a wrong way the value that was coming from a listbox, so the recordset was empty.

        Thankz!!

        Comment

        Working...