Filtering Data From Multiple Recordsets?

Posted on 2005-03-08
Medium Priority
Last Modified: 2010-04-25
I am currently working on a profile page that users will go to once they log in to our website. The profile page will show the users contact information, as well as show any additional items that are relavent to the user like outstanding orders, missing documents etc...

How I have this set up is, there is a table in the database that has all the user's info like name, pass, address, etc.. They login to the site and it validates it baised off that table. Then when they click on the profile link it takes them to the "Profile" page. Once they enter the the profile page I can get the recordset to filter based off of MM_Username and so that recordset loads just fine. But in the second, and third section I want to be able to show the records off a second and third recordset. Now in each table I have a field called salesrepcode that I would like to use to tie all off the records together. So Ideally the page will show just the records associated to that user. Can anyone help me figure out how I can filter the second and third recordsets?

Thanks in advance!

Section#1 Welcome User - Recordset#1 - Table Users
Section#2 Users Information, Address, phone, etc... Recordset#1 - Table Users
Section#3 Order History - Recordset#2 - Table SalesRecords
Section#4 Missing Paperwork - Recordset#3 - Table MissingDocs
Question by:awinstead
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Author Comment

ID: 13500041
Ok after spending hours looking this up I have figured out that I need to create a second Session Variable from my login page that will grab the value of whatever is in the SREP_CODE field. now thr problem I have is placing the new session Variable. Here is the code I am using on my login. Right now the code doesn't seem to send session to the new page. I must be doing something wrong but not sure as to what?

Login code:
<!--#include file="Connections/Main_DB.asp" -->
Dim Employee
Dim Employee_numRows

Set Employee = Server.CreateObject("ADODB.Recordset")
Employee.ActiveConnection = MM_Main_DB_STRING
Employee.Source = "SELECT * FROM Fullemployees"
Employee.CursorType = 0
Employee.CursorLocation = 2
Employee.LockType = 1

Employee_numRows = 0
' *** Validate request to log in to this site.
MM_LoginAction = Request.ServerVariables("URL")
If Request.QueryString<>"" Then MM_LoginAction = MM_LoginAction + "?" + Server.HTMLEncode(Request.QueryString)
If MM_valUsername <> "" Then
  set MM_rsUser = Server.CreateObject(MM_flag)
  MM_rsUser.ActiveConnection = MM_Main_DB_STRING
  MM_rsUser.Source = "SELECT Username, password"
  If MM_fldUserAuthorization <> "" Then MM_rsUser.Source = MM_rsUser.Source & "," & MM_fldUserAuthorization
  MM_rsUser.Source = MM_rsUser.Source & " FROM Fullemployees WHERE Username='" & Replace(MM_valUsername,"'","''") &"' AND password='" & Replace(Request.Form("pwd"),"'","''") & "'"
  MM_rsUser.CursorType = 0
  MM_rsUser.CursorLocation = 2
  MM_rsUser.LockType = 3
  If Not MM_rsUser.EOF Or Not MM_rsUser.BOF Then
    ' username and password match - this is a valid user
    Session("MM_Username") = MM_valUsername
    session("svSaleRep") = Employee.fields.Item("SREP_CODE").value
    If (MM_fldUserAuthorization <> "") Then
      Session("MM_UserAuthorization") = CStr(MM_rsUser.Fields.Item(MM_fldUserAuthorization).Value)
      Session("MM_UserAuthorization") = ""
    End If
    if CStr(Request.QueryString("accessdenied")) <> "" And true Then
      MM_redirectLoginSuccess = Request.QueryString("accessdenied")
    End If
  End If
End If

Accepted Solution

alexhogan earned 1000 total points
ID: 13507348
I think you're heading in the right direction..,

However, you could ease the burden on yourself if you get all of the user info up front.

You have three tables that you are gather data from, correct?

So, let's say that once the user logs on you want to keep resident;

Real Name
Order History - last 5 orders
Missing Paperwork

When you construct your query you should be able to pull all of this data, now all you need to do is keep it in state.

Consider that Session Object are in fact associative array objects, and like arrays they can have multiple dimensions.

Session['username'] // identifies the username
Session['username']['RealName'] // identifies the real name of user (n)
Session['username']['address'] // identifies the address of user (n)
Session['username']['email'] // identifies the email address of user (n)
Session['username']['OrderHistory'] // identifies the order history of user (n), probably a string representing an array that can be parsed
Session['username']['MissingPaperWork'] // identifies the missing paperwork of user (n), again maybe a string representing an array

This may seem a little confusing at first but remember, looping through an array to get specific values is very straight forward.  It's those values that you can, in turn, use for conditions in other queries.

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Adobe Dreamweaver CS5 is a WYSIWYG web page editor that has advanced HTML, CSS, and Javascript rendering functionality and is probably the most well-known HTML editor available. Much of Dreamweaver's appeal centers around the Design View interfac…
This article is very specific and is only intended to help if you are installing Dreamweaver 8 in a Windows 7 environment with Office 2007 installed.   I'm not sure why Microsoft tends to release OS' that should not be released but they do.  Windows…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

801 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question