<%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 = "*" %> Generic View - Information <% if Session("dbBodyTag") & "x" <> "x" Then Response.Write "" Else %> WIDTH="100%">
>
ALIGN="RIGHT" WIDTH="*"> "><%=txtBackToList%>
<%=Session("dbTitle")%> - Information
Connection: <%= strConn %>

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) %>

>
> <% for x = 1 to intFieldCount if x mod 2 = 0 Then bgcolor="#FFFFCC" Else bgcolor="White" end if %> <% aFields(x, 1) = xrs.Fields(x-1).Name %> <% aFields(x, 2) = xrs.Fields(x-1).Type %> <% aFields(x, 3) = xrs.Fields(x-1).DefinedSize %> <% next %>
> FACE="<%=strFont%>">- <%= strTable %> -
FACE="<%=strFont%>"># FACE="<%=strFont%>">Field FACE="<%=strFont%>">Type # FACE="<%=strFont%>">Type FACE="<%=strFont%>">Length
ALIGN="LEFT"> FACE="<%=strFont%>"><%=x %> ALIGN="LEFT"> FACE="<%=strFont%>"><%=aFields(x, 1)%> ALIGN="LEFT"> FACE="<%=strFont%>"><%=aFields(x, 2)%> ALIGN="LEFT"> FACE="<%=strFont%>"> <% Select Case aFields(x,2) Case 2 ' 2-Byte Integer %> 2-Byte Integer <% Case 3 ' 4-Byte Integer %> 4-Byte Integer <% Case 4 ' 2-Byte Real %> 2-Byte Real <% Case 5 ' 4-Byte Real %> 4-Byte Real <% Case 6 ' Currency %> Currency <% Case 7, 135 ' Date / Time Stamp %> Date / Time <% Case 11 ' Boolean True/False %> True/False <% Case 17 ' 1-Byte Integer %> Byte <% Case 129 ' Char %> String (Char) <% Case 130 ' Unicode String %> String (WChar) <% Case 131 ' Numeric - A floating point type %> Numeric <% Case 200 ' String %> String (VarChar) <% Case 201 ' Memo %> Memo (LongVarChar) <% Case 202 ' Unicode String %> Unicode String (VarWChar) <% Case 203 ' Unicode String %> Unicode Memo (LongVarWChar) <% Case 205 ' BLOB %> BLOB (Unsupported) <% end Select %> ALIGN="LEFT"> FACE="<%=strFont%>"><%=aFields(x, 3)%>

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 "


Extended Information
" Response.Write "
Session Variables (" & Session.Contents.Count & ")

" Dim strName, iLoop for each strName in Session.Contents if IsArray(Session(strName)) then Response.Write "

" Else Response.Write "
  • " & strName & " = " & Session.Contents(strName) & "
    " end if next Response.Write "


    Application Variables (" & Application.Contents.Count & ")

    " 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 "


    Form Variables (" & Request.form.Count & ")

    " for each strName in Request.form Response.Write("   " & strName & " = " & Request.form(strName) & "
    ") next Response.Write "


    Query String Variables (" & Request.Querystring.Count & ")

    " for each strName in Request.QueryString Response.Write("   " & strName & " = " & Request.QueryString(strName) & "
    ") next Response.Write "


    Cookie Variables (" & Request.Cookies.Count & ")

    " for each strName in Request.Cookies Response.Write("   " & strName & " = " & Request.Cookies(strName) & "
    ") next Response.Write "


    Server Variables (" & Request.ServerVariables.Count & ")

    " for each strName in Request.ServerVariables Response.Write("

  • " & strName & " = " & Request.ServerVariables(strName) & "
    ") next end if ' Close up shop xrs.Close Set xrs = Nothing xConn.Close Set xConn = Nothing %> <% if Session("dbFooter") = 1 Then %> <% end if %>