%OPTION Explicit%> <% ' Generic Database - Information Page ' Notice: (c) 1998, 1999, 2000 Eli Robillard, All Rights Reserved. ' E-Mail: erobillard@ofifc.org ' URL: http://www.ofifc.org/Eli/ASP/ ' Revision History: ' 29 Feb 2000 - Extended information based on debug.asp, provided by Grant Wilson ' 21 Jan 2000 - OLEDB Connection Support ' 29 Oct 1999 - Added dbMenuTextColor, dbBodyTag ' 14 Jul 1999 - Added Response.Clear before Redirect for boneheaded MSIE browsers ' 28 Jun 1999 - Query displayed in SELECT...FROM...WHERE...GROUPBY...ORDERBY format ' 9 Sep 1998 - Last modified ' Set the following to true to display all settings ShowExtendedInformation = True On Error Resume Next ' Prevent caching Response.Buffer = True Response.ExpiresAbsolute = Now() - 1 Response.AddHeader "cache-control", "must-revalidate" Response.AddHeader "cache-control", "private" Response.AddHeader "pragma", "no-cache" ' Declare vars Dim strType, strConn, strTable, strFields, strDisplay, strKeyField, strGroupBy, strFont, strFontSize, strBorderColor, strMenuColor, strMenuTextColor, xConn, xRs, ShowExtendedInformation, intFontSize, strsql, intFieldCount, x, y, z, bgcolor ' Check for an active session if Session("dbConn") & "x" = "x" Then Response.Clear Response.Redirect "GenericError.asp" end if ' Check for user rights if Session("dbDebug") <> 1 Then Response.Clear Response.Redirect Session("dbViewPage") end if ' Get info from Session vars strType = UCase(Session("dbType")) strConn = Session("dbConn") strTable = Session("dbRs") strFields = Session("dbFields") strDisplay = Session("dbDispView") strKeyField = Session("dbKey") strGroupBy = Session("dbGroupBy") strFont = Session("dbFont") intFontSize = Session("dbFontSize") strBorderColor = Session("dbBorderColor") strMenuColor = Session("dbMenuColor") strMenuTextColor = Session("dbMenuTextColor") ' Open Connection to the database set xConn = Server.CreateObject("ADODB.Connection") xConn.Open strConn ' Check and set fonts and colours if strBorderColor & "x" = "x" Then strBorderColor = "#99CCCC" if strFont & "x" = "x" Then strFont = "Arial" if Not (intFontSize > 0) Then intFontSize = 2 if strMenuColor & "x" = "x" Then strMenuColor = "#99CCCC" if strMenuTextColor & "x" = "x" Then strMenuTextColor = "Black" if strFields & "x" = "x" then strFields = "*" %>
|
Query:
SELECT <%= strFields %>
FROM <%= Session("dbRs") %>
WHERE <%= Session("dbWhere") %>
GROUP BY <%= strGroupBy %>
HAVING <%= Session("dbHaving") %>
ORDER BY <%= Session("dbOrderBy") %>
<% ' Open Recordset and get the field info strsql = "SELECT " & strFields & " FROM [" & strTable & "]" Select Case strType Case "UDF" strsql = "SELECT " & strFields & " FROM " & strTable Case "SQL" strsql = Replace(strsql,"[","") strsql = Replace(strsql,"]","") end Select if Not strGroupBy & "x" = "x" Then strsql = strsql & " GROUP BY " & strGroupBy set xrs = Server.CreateObject("ADODB.Recordset") xrs.Open strsql, xConn, 1, 2 intFieldCount = xrs.Fields.Count Dim aFields() ReDim aFields(intFieldCount,4) %>
| |||||||||||||||
Current Order set by:
<% if Session("dbOrder") > 0 Then %>
Session("dbOrder") = <%= Session("dbOrder") %>
<% Else %>
Session("dbOrderBy") = <%= Session("dbOrderBy") %>
<% end if %>
Cut and Paste the following to build a custom list of field names:
Session("dbFieldNames") = "<%
for x = 1 to intFieldCount - 1
Response.Write aFields(x, 1) & ", "
next
Response.Write aFields(intFieldCount, 1) & chr(34)
if ShowExtendedInformation then
Response.Write "
" Dim strName, iLoop for each strName in Session.Contents if IsArray(Session(strName)) then Response.Write "
"
for each strName in Application.Contents
if IsArray(Application(strName)) then
for iLoop = LBound(Application(strName)) to UBound(Application(strName))
Response.Write " " & strName & "(" & iLoop & ") - " & Application(strName)(iLoop) & "
"
next
Else
Response.Write " " & strName & " - " & Application.Contents(strName) & "
"
end if
next
Response.Write "
"
for each strName in Request.form
Response.Write(" " & strName & " = " & Request.form(strName) & "
")
next
Response.Write "
"
for each strName in Request.QueryString
Response.Write(" " & strName & " = " & Request.QueryString(strName) & "
")
next
Response.Write "
"
for each strName in Request.Cookies
Response.Write(" " & strName & " = " & Request.Cookies(strName) & "
")
next
Response.Write "
" for each strName in Request.ServerVariables Response.Write("