<% OPTION Explicit ' Generic Database - Exit ' Notice: (c) 1998, 1999, 2000 Eli Robillard, All Rights Reserved. ' E-Mail: erobillard@ofifc.org ' URL: http://www.ofifc.org/Eli/ASP/ ' Revision History: ' 08 Jun 2000 - Subtable support fixed ' Back button survives after session timeout ' 22 May 2000 - Session var reset was clearing all vars, now limited to db* ' 22 Mar 2000 - Fixed something with subtables / returning from subtables ' Rewrote the routine to reset session vars ' 07 Feb 2000 - Only blank session vars if they exist (with NOT IsEmpty()) ' 14 Jul 1999 - Added Response.Clear before Redirect for boneheaded MSIE browsers ' 6 Jul 1999 - Fix for subtables as suggested by Paul Reith ' 5 May 1999 - Fixed redirect problem for time-outs. Now redirect to GenericError. ' 23 Feb 1999 - Added an option to reset rather than exit (redirect back to Lister). ' 30 Nov 1998 - First created or released Response.Buffer = true ' Var declaration DIM doReset, doOpenSubTable, xConn, xrs, x, y, z, QUOTE DIM arrSubtable DIM strCmd, strKey, subkey, strConn, strExitPage, strName, strsql, strSubTable, strTable, strType, strUName, strURL, strViewPage DIM intFieldCount QUOTE = chr(34) doReset = False ' True if reset was selected, means we re-read the config file doOpenSubTable = False ' True if opening a subtable ' Quick security check, make sure we have an active session if (Session("dbDispList") & "x" = "x") or (Session("dbConn") & "x" = "x") Then if Request.Querystring("EXIT").Count > 0 then strExitPage = Request.Querystring("EXIT") strExitPage = Replace(strExitPage,"'","") Response.Redirect strExitPage else Response.Redirect "GenericError.asp" end if end If ' Get the key value of the record to display If Request.QueryString("KEY").Count > 0 AND (Session("dbSubTable") & "x" <> "x") Then strSubTable = Session("dbSubTable") doOpenSubTable = True strKey = Request.QueryString("KEY") ' Suggested by Paul Reith: Session("dbsubkey") = strKey End If ' See if this is a reset (not an exit) If Request.QueryString("CMD").Count > 0 Then strCmd = Request.QueryString("CMD") select case strCmd case "'Reset'" doReset = True end select End If ' Get the parameters set in the Config File strType = UCase(Session("dbType")) strConn = Session("dbConn") strTable = Session("dbRs") strExitPage = Session("dbExitPage") strViewPage = Session("dbViewPage") ' Open Recordset and get the field count set xConn = Server.CreateObject("ADODB.Connection") xConn.Open strConn strsql = "SELECT * FROM [" & strTable & "]" Select Case strType Case "UDF" strsql = "SELECT * FROM " & strTable Case "SQL" strsql = Replace(strsql,"[","") strsql = Replace(strsql,"]","") End Select set xrs = Server.CreateObject("ADODB.Recordset") xrs.Open strsql, xConn intFieldCount = xrs.Fields.Count xrs.Close Set xrs = Nothing xConn.Close Set xConn = Nothing ' Reset session vars for each strName in Session.Contents strUName = UCase(strName) ' clear db* vars, keep settings used during subtables if (left(strUName,2) = "DB") AND NOT( (instr(1, strUName, "SUB") > 0) OR (strUName = "DBLASTRS") OR (strUName = "DBWHERE")) then if IsArray(Session(strName)) then for iLoop = LBound(Session(strName)) to UBound(Session(strName)) Session(strName)(iLoop) = Null next Else Session.Contents(strName) = Null end if end if next if doOpenSubTable then ' If going to a sub-table arrSubTable = Split(strSubTable,",") ' Copy the SubTable parm and clear it so it doesn't think there are more below this one. Session("dbSubTableCopy") = strSubTable Session("dbSubTable") = "" Session("dbSubParent") = strViewPage Session("dbIsSubTable") = True Session("dbWhere") = arrSubTable(2) & " = " & strKey strURL = arrSubTable(1) Response.Clear Response.Redirect strURL end if if doReset then ' reread the config file Response.Clear Response.Redirect strViewPage end if ' Exit GenericDB Session("dbSubTableCopy") = "" Session("dbSubParent") = "" Session("dbSubTable") = "" Session("dbIsSubTable") = False Session("dbWhere") = "" Response.Clear Response.Redirect strExitPage %>