dcsimg
  Home | Windows Servers | SQL Server | SMS Server | Exchange Server | Windows Scripts | SQL Scripts | Discussions | Columnists




 Swynk.com »
   Windows Servers
   Windows Scripts
   SQL Server
   SQL Scripts
   SMS Server
   Exchange Server






 Resources »
   Discussion Groups
   Discussion Lists
   Columnists
   Newsletter
   Knowledgebase
   Jobbase
   Online Library


 




Internet News
Internet Investing
Internet Technology
Windows Internet Tech.
Linux/Open Source
Web Developer
ECommerce/ Marketing
ISP Resources
ASP Resources
Wireless Internet
Downloads
Internet Resources
Internet Lists
International
EarthWeb
Career Resources

Search internet.com
Advertise
Corporate Info
Newsletters
E-mail Offers

internet.commerce

Be a Partner










Make SWYNK.COM
Your Home Page




  *archives (robots only)


  Swynk.com > the admin subsystem


October 21, 2002

filename: show_table.asp

Cut and paste the code below into a text editor like notepad or Visual Interdev and save to the root of the web application. (As always with cut-n-paste from a web page, be wary of word wrap.)

<!--#include file="adovbs.inc"-->
<%DIM cn
  DIM cm 
  DIM rs    
  DIM n
  DIM m 
  DIM currDate, yr, mo, day
  DIM currTime, hr, min, sec 

  On Error Resume Next

  m=0

  SET cn = Server.CreateObject("ADODB.Connection")
  SET cm = Server.CreateObject("ADODB.Command")

  'get the connection string from global.asa
  cn.open Application("admin_ConnectionString")

  SET cm.Activeconnection = cn

  'build a query to get the requested data
  If (Request.Querystring("sp") <> "") Then
    cm.CommandText = Request.Querystring("sp")
    If Request.Querystring("procedure") <> "" Then
      cm.Parameters.Append cm.CreateParameter("@name", adVarChar, adParamInput, 30)
      cm("@name") = TRIM(Request.QueryString("procedure"))
    End If
    cm.CommandType = adCmdStoredProc	
  ELSE
    cm.CommandText = "SELECT "
    If (Request.Querystring("columnList") <> "") Then
      cm.CommandText = cm.CommandText + Request.Querystring("columnList")
    Else
      cm.CommandText = cm.CommandText + "*"
    End If
    cm.CommandText = cm.CommandText + " FROM " 
    cm.CommandText = cm.CommandText + Request.Querystring("table")
    If (Request.Querystring("condition") <> "") Then 
      cm.CommandText = cm.CommandText + " " + Request.Querystring("condition")
      If (Request.Querystring("table") = "admin..sysobjects") Then
        cm.CommandText = cm.CommandText + " AND name NOT LIKE 'dt_%' ORDER BY name"
      End If
    End If 

    cm.CommandType = adCmdText	
  End If

  'run the query
  If err.number = 0 Then
    SET rs = cm.Execute
  End If

  SET cm.Activeconnection = nothing

  Response.Write "<HTML><HEAD><TITLE></TITLE>" + vbCrLf

  'if we are looking at systasks build a compare date and time
  For n = 0 to rs.Fields.count - 1
    If rs.Fields(n).name = "lastruncompletionlevel" Then 
      'set flag to indicate this is systasks for later use
      m = 1
      yr = CStr(DatePart("yyyy",DATE))
      mo = CStr(DatePart("m",DATE))
      IF len(mo) = 1 Then mo = "0" + mo 
      day = CStr(DatePart("d",DATE))  
      IF len(day) = 1 Then day = "0" + day 
      currDate = CLng(yr + mo + day)
      hr = CStr(DatePart("h",TIME))
      min = CStr(DatePart("n",TIME))
      If len(min) = 1 Then min = "0" + min        
      sec = "00"
      currTime = CLng(hr + min + sec)
    End If
  Next

  Response.Write "</HEAD>" + vbCrLf
  Response.Write "<BODY>" + vbCrLf
  Response.Write "<FORM>" + vbCrLf

  'handle any error and report it to the browser 
  If  err.number <> 0 Then
    Response.Write "VBScript Errors Occured:" & "<P>"
    Response.Write "Error Number=" & err.number & "<P>"
    Response.Write "Error Descr.=" & err.description & "<P>"
    Response.Write "Help Context=" & err.helpcontext & "<P>" 
    Response.Write "Help Path=" & err.helppath & "<P>"
    Response.Write "Native Error=" & err.nativeerror & "<P>"
    Response.Write "Source=" & err.source & "<P>"
    Response.Write "SQLState=" & err.sqlstate & "<P>"

    If  cn.errors.count > 0 Then
      Response.Write "<P>" & "Database Errors Occured" & "<P>"
      For n = 0 to cn.errors.count
        Response.Write "Error #" & cn.errors(n).number & "<P>"
        Response.Write "Error desc. -> " & cn.errors(n).description & "<P>"
      Next
    End If
  Else
    Response.Write "<TABLE BORDER='1'>" + vbCrLf
    If m = 1 Then
      Response.Write "<CAPTION ALIGN='center'>Status of Active Tasks</CAPTION>" + vbCrLf
    End If
    Response.Write "<TR>" + vbCrLf
    For n = 0 to rs.Fields.count - 1
      IF rs.Fields(n).name <> "lastruncompletionlevel" Then
        Response.Write "<TH><FONT SIZE=2>" + vbCrLf
        Response.Write rs.Fields(n).name + vbCrLf
        Response.Write "</FONT></TH>" + vbCrLf
      End If
    Next
    Response.Write "</TR>" + vbCrLf

    'write the result set to a table
    While (Not rs.EOF)
      Response.Write "<TR>" + vbCrLf
      For n = 0 to rs.Fields.count - 1
        'color code systasks output
        IF rs.Fields(n).name <> "lastruncompletionlevel" Then
          IF m = 1 Then
            Response.Write "<TD BGCOLOR='"
            If rs.Fields("nextrundate") = 0 Then 
              Response.Write "LightGrey"
            ElseIf  currDate = rs.Fields("nextrundate") _
            And currTime < rs.Fields("nextruntime") Then
              Response.Write "PaleGreen"
            ElseIf currDate = rs.Fields("nextrundate") _
            And currTime > rs.Fields("nextruntime") Then
              Response.Write "PapayaWhip"
            ElseIf currDate > rs.Fields("nextrundate") Then
              Response.Write "PapayaWhip"
            Else
              Response.Write "White"
            End if
            If n > 0 Then
              Response.Write "' ALIGN='right" 
            End If
            Response.Write "' NOWRAP>" + vbCrLf
            If rs.Fields("lastruncompletionlevel").value = 0 Then
              Response.Write "<FONT COLOR='red' SIZE=2>" + vbCrLf
            Else
              Response.Write "<FONT COLOR='black' SIZE=2>" + vbCrLf
            End If               
          Else
            Response.Write "<TD NOWRAP>" + vbCrLf
            Response.Write "<FONT COLOR='black' SIZE=2>" + vbCrLf
          End If 
          If rs.Fields(n).name = "lastrundate" _
          Or rs.Fields(n).name = "nextrundate" Then
            Response.Write MID(rs.Fields(n).value,5,2) + "-" + _
                           MID(rs.Fields(n).value,7,2) + "-" + _
                           MID(rs.Fields(n).value,1,4)
          ElseIf rs.Fields(n).name = "lastruntime" _
          Or rs.Fields(n).name = "nextruntime" _
          Or rs.Fields(n).name = "hhmmss" Then
            If rs.Fields(n).value = 0 Then
              Response.Write "midnight"
            Else
              If len(rs.Fields(n).value) > 4 Then
                Response.write MID(rs.Fields(n).value,1,len(rs.Fields(n).value) - 4) 
              Else 
                Response.Write "00"
              End If 
              Response.Write":"
              If len(rs.Fields(n).value) > 2 Then
                Response.Write Left(Right(rs.Fields(n).value,4),2) 
              Else 
                Response.Write "00"
             End If 
             Response.Write":"
             Response.write Right(rs.Fields(n).value,2)
           End If
         Else 
           Response.Write rs.Fields(n).value
         End If 
         Response.Write "</FONT>" + vbCrLf
         Response.Write "</TD>" + vbCrLf
       End If
     Next
     Response.Write "</TR>" + vbCrLf
     rs.MoveNext
   Wend
   Response.Write "</TABLE>" + vbCrLf
  End If  

  Response.Write "</FORM>" + vbCrLf
  Response.Write "</BODY></HTML>" + vbCrLf

  SET rs=nothing
  cn.close
%>


Rate This Page :




Jupitermedia Corp.


home | search | newsletter | windows | sql | sms | exchange


Copyright © 2002 Jupitermedia Corp. All Rights Reserved.

Licensing, Reprints, and Permissions Information

About Jupitermedia Corp. | Swynk.com

Privacy Policy | Press Releases