Classic ASP join tables from different connections

Enlittalf

New Member
Let's say you have a system which records workers clocking in and out.Each time they clock in/out, this is recorded in a Transactions database in a table named Transactions. One row per clock in/out is recorded, with the date/time, etc.Each record has a field called "exception" which is a boolean which denotes whether that record is an exception or not (e.g. have they clocked out too early, had a short lunch, etc.). For each of these exception transactions, another table is updated (in the same database), and this is called Exceptions. One row is present for each row in Transactions this is set an an exception. These records in the "Exceptions" table have a field called ExceptionType which is a number which denotes the type of the exception.However, the lookup table which tells you what this ExceptionType means is in a completely different database, and I cannot copy it over. I am writing a Classic ASP page to report the clock data from Transactions. I will need to write both normal transactions, and exceptions transactions. However, I only want certain types of exception transactions, not all. The current recordsets are below. TokenNum represents the employee.RS's for the Clock In and Clock Outs\[code\]SQLIn = "SELECT Date, Time, Transactions.[Exception] " & _ "FROM Transactions " & _ "WHERE TokenNumber = " & TokenNo & " " & _ "AND Date >= " & FromDateG & " " & _ "AND Direction = -1 " & _ "ORDER BY Date, TransactionNumber;"Set RSIn = Server.CreateObject("ADODB.RecordSet")RSIn.Open SQLIn, TransConn,1 ,1SQLOut = "SELECT Date, Time, Transactions.[Exception] " & _ "FROM Transactions " & _ "WHERE TokenNumber = " & TokenNo & " " & _ "AND Date >= " & FromDateG & " " & _ "AND Direction = 0 " & _ "ORDER BY Date, TransactionNumber;"Set RSOut = Server.CreateObject("ADODB.RecordSet")RSOut.Open SQLOut, TransConn,1 ,1\[/code\]RS's for the Exceptions and the reasons;\[code\]SQLExcep = "SELECT Date, TransactionTime, ExceptionsNumber, ExceptionType " & _ "FROM Exceptions " & _ "WHERE TokenNumber = " & TokenNo & " " & _ "AND Date >= " & FromDateG & " " & _ "ORDER BY Date, ExceptionsNumber;"Set RSExcep = Server.CreateObject("ADODB.RecordSet")RSExcep.Open SQLExcep, TransConn,1 ,1SQLExcepRsn = "SELECT fNumber, fName " & _ "FROM ExceptionTypes " Set RSExcepRsn = Server.CreateObject("ADODB.RecordSet")RSExcepRsn.Open SQLExcepRsn, GenConn,1 ,1\[/code\]A table then outputs the data in the following configuration;\[code\]<table border=1><thead><tr><th>Date</th><th>In</th><th>Out</th><th>Exceptions</th></tr></thead>\[/code\]This shows all transactions (clock ins/out), including all exceptions, with the reason from Exception. I am extracting the reason using a While loop\[code\]<td><%'<< EXCEPTIONS'If records present, then move to first exception record If RSExcep.RecordCount > 0 ThenRSExcep.MoveFirstEnd If'if present for this date, display the adjustment time and the type of exceptionDo While Not RSExcep.EOF If RS("Date") = RSExcep("Date") Then 'display exception time toHourMin(RSExcep("TransactionTime")) 'display exception type for this record RSExcepRsn.MoveFirst Do While Not RSExcepRsn.EOF If RSExcepRsn("fNumber") = RSExcep("ExceptionType") Then Response.Write(" - " & RSExcepRsn("fName")) End If RSExcepRsn.MoveNext Loop%> <br/><% End IfRSExcep.MoveNextLoop%></td>\[/code\]This while loop is within another while loop.However, I only want the clocks to be displayed (and the exception type shows) where the exceptions are certain types, e.g. not all exceptions.I cannot join the ExceptionsTypes table to the Exceptions table (and therefore to Transactions) in order to do this.Any advise?
 
Back
Top