Tip of the Day!
By Ian Vink
When you need to create complex SQL, create the Joins, Links and Relationships in Microsft Access
then switch to SQL view and copy the SQL to your ASP page. It ensures the syntax is correct.
**********************************************************************
Tip of the Day!
By Sandra Gopikrishna
ASP.NET replaces VBScript with VB for server side scripting. The VB.NET that is being used in
ASP.NET has the following changes:
1. Set and Let are removed
2. No more default properties
3. Parenthesis are made mandatory to call Subs
4. Arguments are now ByVal by default
5. Integer is now 32 bit, Long is 64 bit
6. All types are strongly typed.
**********************************************************************
Tip of the Day!
By Srinivasa Sivakumar
List all the COM classes from ASP:
<%
Function ShowCOMClasses(vComputerName)
Dim objLocator, objService, objWEBMCol, objWEBM
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
'Establish a connection to WMI
If isEmpty(vServerName) = True then
Set objService = objLocator.ConnectServer
Else
Set objService = objLocator.ConnectServer(vComputerName)
End If
'Get the Webm Service object
Set objWEBMCol = objService.InstancesOf("Win32_ClassicCOMClass")
Response.write "<H2>COM Classes:</H2><HR><UL>"
'Enumerate
For Each objWEBM in objWEBMCol
Response.write "<LI>Caption: " & objWEBM.Caption & _
", <BR>Component ID: " & objWEBM.ComponentId & _
", <BR>Installed Date: " & objWEBM.InstallDate & _
", <BR>Description: " & objWEBM.Description & _
", <BR>Name: " & objWEBM.Name & _
", <BR>Status: " & objWEBM.Status & "<BR></LI>"
Next
Response.write "</UL>"
'Clean up
Set objLocator = Nothing
Set objService = Nothing
Set objWEBMCol = Nothing
Set objWEBM = Nothing
End Function
Call ShowCOMClasses("vComputerName")
%>
Note: Pass the computer name as the parameter. An empty string will work when you are accessing
the local computer.
**********************************************************************
Tip of the Day!
By Sandra Gopikrishna
ASP.NET Pages are designed to be more scalable. The session state can now be maintained in a
separate process, on a separate machine, or even in a database allowing for cross server
sessions. This allows us to relatively easily add more web servers as our traffic grows even if
we hadn't thought about it and planned for it during development.
**********************************************************************
Tip of the Day!
By Gregory Brown
With a default installation, you may start to get some left over connections in Oracle. to solve
this, edit the file "oraodbc.ini" located in your "windows/system" directory, setting the value
LOCKTIMEOUT=XX - where XX is diferent to 0. (I used 60 and it worked fine).
**********************************************************************
Today's ASPToday Article: http://www.asptoday.com/content/articles/20010306.asp
Creating a Light Weight Graphing Solution with XSL, XML and CSS
Tip of the Day!
By Ian Vink
If you're setting up a web farm you can direct the user to the server they came from by using the
server variable: SERVER_NAME in your HREF.
<a HREF='http://<%=Request.ServerVariables("SERVER_NAME")%>/default.asp' target=_top>Home</a>
**********************************************************************
Today's ASPToday Article: http://www.asptoday.com/content/articles/20010307.asp
Using ADSI and Groups on Windows 2000
Tip of the Day!
By Srinivasa Sivakumar
<%
Function showprocessors(vComputerName)
Dim objLocator, objService, objWEBMCol, objWEBM, mycompname, strResult
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
'Establish a connection to WMI
If IsEmpty("vComputerName") = True Then
Set objService = objLocator.ConnectServer
Else
Set objService = objLocator.ConnectServer("vComputerName")
End If
'Get the Webm Service object
Set objWEBMCol = objService.InstancesOf("Win32_Processor")
Response.write "<H2>Processor Info:</H2><HR><UL>"
'Enumerate
For Each objWEBM In objWEBMCol
Response.write "<LI>Caption: " & objWEBM.Caption & _
", <BR>Availability: " & objWEBM.Availability & _
", <BR>Architecture: " & objWEBM.Architecture & _
", <BR>Description: " & objWEBM.Description & _
", <BR>CPU Status: " & objWEBM.CpuStatus & _
", <BR>Current Clock Speed: " & objWEBM.CurrentClockSpeed & _
", <BR>Current Voltage: " & objWEBM.CurrentVoltage & _
", <BR>Data Width: " & objWEBM.DataWidth & _
", <BR>External clock frequency: " & objWEBM.ExtClock & _
", <BR>L2 Cache Size: " & objWEBM.L2CacheSize & _
", <BR>L2 Cache Speed: " & objWEBM.L2CacheSpeed & _
", <BR>Manufacturer: " & objWEBM.Manufacturer & _
", <BR>Max Clock Speed: " & objWEBM.MaxClockSpeed & _
", <BR>Processor ID: " & objWEBM.ProcessorId & _
", <BR>Processor Type: " & objWEBM.ProcessorType & _
", <BR>Status: " & objWEBM.Status & _
", <BR>Status Info: " & objWEBM.StatusInfo & _
", <BR>Processor Family: " & objWEBM.Family & "<BR></LI>"
Next
Response.write "</UL>"
'Clean up
Set objLocator = Nothing
Set objService = Nothing
Set objWEBMCol = Nothing
Set objWEBM = Nothing
End Function
Call ShowProcessors("vComputerName")
%>
**********************************************************************
**********************************************************************
Tip of the Day!
By Srinivasa Sivakumar
<%
Function ShowNTUserAccounts(vComputerName)
Dim objLocator, objService, objWEBMCol, objWEBM
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
'Establish a connection to WMI
If isEmpty("vServerName") = True then
Set objService = objLocator.ConnectServer
Else
Set objService = objLocator.ConnectServer("vComputerName")
End If
'Get the Webm Service object
Set objWEBMCol = objService.InstancesOf("Win32_Account")
Response.write "<H2>NT User Accounts:</H2><HR><UL>"
'Enumerate
For Each objWEBM in objWEBMCol
Response.write "<LI>Caption: " & objWEBM.Caption & _
", <BR>Description: " & objWEBM.Description & _
", <BR>Domain: " & objWEBM.Domain & _
", <BR>Security identifier: " & objWEBM.SID & _
", <BR>SID Type: " & objWEBM.SIDType & _
", <BR>Status: " & objWEBM.Status & "<BR></LI>"
Next
Response.write "</UL>"
'Clean up
Set objLocator = Nothing
Set objService = Nothing
Set objWEBMCol = Nothing
Set objWEBM = Nothing
End Function
Call ShowNTUserAccounts("vComputerName")
%>
Note: Pass the computer name as the parameter. An empty string will work when you are accessing
the local computer.
**********************************************************************
Tip of the Day!
By Srinivasa Sivakumar
<%
Function ShowProcesses(vComputerName)
Dim objLocator, objService, objWEBMCol, objWEBM
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
'Establish a connection to WMI
If isEmpty("vComputerName") = True then
Set objService = objLocator.ConnectServer
Else
Set objService = objLocator.ConnectServer("vComputerName")
End If
'Get the Webm Service object
Set objWEBMCol = objService.InstancesOf("Win32_Process")
Response.write "<H2>Current Running Processes:</H2><HR><UL>"
'Enumerate
For Each objWEBM in objWEBMCol
Response.write "<LI>Process ID: " & objWEBM.ProcessId & _
", <BR>Description: " & objWEBM.Description & _
", <BR>Executable Path: " & objWEBM.ExecutablePath & _
", <BR>Execution State: " & objWEBM.ExecutionState & _
", <BR>Parent Process ID: " & objWEBM.ParentProcessId & _
", <BR>Priority: " & objWEBM.Priority & _
", <BR>Status: " & objWEBM.Status & "<BR></LI>"
Next
Response.write "</UL>"
'Clean up
Set objLocator = Nothing
Set objService = Nothing
Set objWEBMCol = Nothing
Set objWEBM = Nothing
End Function
Call ShowProcesses("vComputerName")
%>
Note: Pass the computer name as the parameter. An empty string will work when you are accessing
the local computer.
**********************************************************************
**********************************************************************
Tip of the Day!
By Srinivasa Sivakumar
How to list all the running Windows services from ASP:
<%
Function ShowServices(vComputerName)
Dim objLocator, objService, objWEBMCol, objWEBM
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
'Establish a connection to WMI
If isEmpty(vComputerName) = True then
Set objService = objLocator.ConnectServer
Else
Set objService = objLocator.ConnectServer(vComputerName)
End If
'Get the Webm Service object
Set objWEBMCol = objService.InstancesOf("Win32_Service")
Response.write "<H2>Windows Services:</H2><HR><UL>"
'Enumerate
For Each objWEBM in objWEBMCol
Response.write "<LI>Caption: " & objWEBM.Caption & _
", <BR>Description: " & objWEBM.Description & _
", <BR>Display Name: " & objWEBM.DisplayName & _
", <BR>Path Name: " & objWEBM.PathName & _
", <BR>State: " & objWEBM.State & _
", <BR>Status: " & objWEBM.Status & _
", <BR>System Name: " & objWEBM.SystemName & "<BR></LI>"
Next
Response.write "</UL>"
'Clean up
Set objLocator = Nothing
Set objService = Nothing
Set objWEBMCol = Nothing
Set objWEBM = Nothing
End Function
Call ShowServices("vComputerName")
%>
Note: Pass the computer name as the parameter. An empty string will work when you are accessing
the local computer.
**********************************************************************
**********************************************************************
Tip of the Day!
By Srinivasa Sivakumar
List the Windows Boot Configuration from ASP:
<%
Function ShowNTBootConfiguration(vComputerName)
Dim objLocator, objService, objWEBMCol, objWEBM
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
'Establish a connection to WMI
If isEmpty(vServerName) = True then
Set objService = objLocator.ConnectServer
Else
Set objService = objLocator.ConnectServer(vComputerName)
End If
'Get the Webm Service object
Set objWEBMCol = objService.InstancesOf("Win32_BootConfiguration")
Response.write "<H2>Boot Configuration:</H2><HR><UL>"
'Enumerate
For Each objWEBM in objWEBMCol
Response.write "<LI>Caption: " & objWEBM.Caption & _
", <BR>Boot Directory: " & objWEBM.BootDirectory & _
", <BR>Configuration Path: " & objWEBM.ConfigurationPath & _
", <BR>Description: " & objWEBM.Description & _
", <BR>Last Drive: " & objWEBM.LastDrive & _
", <BR>Scratch Directory: " & objWEBM.ScratchDirectory & _
", <BR>Temp Directory: " & objWEBM.TempDirectory & "<BR></LI>"
Next
Response.write "</UL>"
'Clean up
Set objLocator = Nothing
Set objService = Nothing
Set objWEBMCol = Nothing
Set objWEBM = Nothing
End Function
Call ShowNTBootConfiguration("vComputerName")
%>
Note: Pass the computer name as the parameter. An empty string will work when you are accessing
the local computer.
**********************************************************************
**********************************************************************
Tip of the Day!
By Srinivasa Sivakumar
List all the COM Applications from ASP:
<%
Function ShowCOMApplications(vComputerName)
Dim objLocator, objService, objWEBMCol, objWEBM
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
'Establish a connection to WMI
If isEmpty(vServerName) = True then
Set objService = objLocator.ConnectServer
Else
Set objService = objLocator.ConnectServer(vComputerName)
End If
'Get the Webm Service object
Set objWEBMCol = objService.InstancesOf("Win32_COMApplication")
Response.write "<H2>COM Applications:</H2><HR><UL>"
'Enumerate
For Each objWEBM in objWEBMCol
Response.write "<LI>Caption: " & objWEBM.Caption & _
", <BR>Applicaiton ID: " & objWEBM.AppID & _
", <BR>Description: " & objWEBM.Description & _
", <BR>Install Date: " & objWEBM.InstallDate & _
", <BR>Name: " & objWEBM.Name & _
", <BR>Status: " & objWEBM.Status & "<BR></LI>"
Next
Response.write "</UL>"
'Clean up
Set objLocator = Nothing
Set objService = Nothing
Set objWEBMCol = Nothing
Set objWEBM = Nothing
End Function
Call ShowCOMApplications("vComputerName")
%>
Note: Pass the computer name as the parameter. An empty string will work when you are accessing
the local computer.
**********************************************************************
**********************************************************************
Tip of the Day!
By Srinivasa Sivakumar
List the current Windows configuration information from ASP:
<%
Function ShowOSOptions(vComputerName)
Dim objLocator, objService, objWEBMCol, objWEBM
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
'Establish a connection to WMI
If isEmpty(vServerName) = True then
Set objService = objLocator.ConnectServer
Else
Set objService = objLocator.ConnectServer(vComputerName)
End If
'Get the Webm Service object
Set objWEBMCol = objService.InstancesOf("Win32_ComputerSystem")
Response.write "<H2>OS Options:</H2><HR><UL>"
'Enumerate
For Each objWEBM in objWEBMCol
Response.write "<LI>Caption: " & objWEBM.Caption & _
", <BR>Admin Password Status: " & objWEBM.AdminPasswordStatus & _
", <BR>Automatic Reset Boot Option: " & objWEBM.AutomaticResetBootOption & _
", <BR>Boot Option On Limit: " & objWEBM.BootOptionOnLimit & _
", <BR>Boot ROM Supported: " & objWEBM.BootROMSupported & _
", <BR>Bootup State: " & objWEBM.BootupState & _
", <BR>Current Time Zone: " & objWEBM.CurrentTimeZone & _
", <BR>Daylight In Effect: " & objWEBM.DaylightInEffect & _
", <BR>Domain: " & objWEBM.Domain & _
", <BR>Domain Role: " & objWEBM.DomainRole & _
", <BR>Manufacturer: " & objWEBM.Manufacturer & _
", <BR>Model: " & objWEBM.Model & _
", <BR>Number Of Processors: " & objWEBM.NumberOfProcessors & _
", <BR>Power State: " & objWEBM.PowerState & _
", <BR>Status: " & objWEBM.Status & _
", <BR>System Startup Delay: " & objWEBM.SystemStartupDelay & _
", <BR>System Type: " & objWEBM.SystemType & _
", <BR>Current User Name: " & objWEBM.UserName & "<BR></LI>"
Next
Response.write "</UL>"
'Clean up
Set objLocator = Nothing
Set objService = Nothing
Set objWEBMCol = Nothing
Set objWEBM = Nothing
End Function
Call ShowOSOptions("vComputerName")
%>
Note: Pass the computer name as the parameter. An empty string will work when you are accessing
the local computer.
**********************************************************************
**********************************************************************
Tip of the Day!
By Srinivasa Sivakumar
List all the Computer Information from ASP:
<%
Function ShowSystemProduct(vComputerName)
Dim objLocator, objService, objWEBMCol, objWEBM
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
'Establish a connection to WMI
If isEmpty(vComputerName) = True then
Set objService = objLocator.ConnectServer
Else
Set objService = objLocator.ConnectServer(vComputerName)
End If
'Get the Webm Service object
Set objWEBMCol = objService.InstancesOf("Win32_ComputerSystemProduct")
Response.write "<H2>Computer Information:</H2><HR><UL>"
'Enumerate
For Each objWEBM in objWEBMCol
Response.write "<LI>Caption: " & objWEBM.Caption & _
", <BR>Description: " & objWEBM.Description & _
", <BR>Name: " & objWEBM.Name & _
", <BR>Product ID: " & objWEBM.IdentifyingNumber & _
", <BR>Stock Keeping Unit Number: " & objWEBM.SKUNumber & _
", <BR>Universally unique identifier: " & objWEBM.UUID & _
", <BR>Vendor: " & objWEBM.Vendor & _
", <BR>Version: " & objWEBM.Version & "<BR></LI>"
Next
Response.write "</UL>"
'Clean up
Set objLocator = Nothing
Set objService = Nothing
Set objWEBMCol = Nothing
Set objWEBM = Nothing
End Function
Call ShowSystemProduct("vComputerName")
%>
**********************************************************************
**********************************************************************
Tip of the Day!
By Srinivasa Sivakumar
List all network clients installed from ASP:
<%
Function ShowNetworkClients(vComputerName)
Dim objLocator, objService, objWEBMCol, objWEBM
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
'Establish a connection to WMI
If isEmpty(vComputerName) = True then
Set objService = objLocator.ConnectServer
Else
Set objService = objLocator.ConnectServer(vComputerName)
End If
'Get the Webm Service object
Set objWEBMCol = objService.InstancesOf("Win32_NetworkClient")
Response.write "<H2> Network Clients Installed:</H2><HR><UL>"
'Enumerate
For Each objWEBM in objWEBMCol
Response.write "<LI>Name: " & objWEBM.Name & _
", <BR>Caption: " & objWEBM.Caption & _
", <BR>Description: " & objWEBM.Description & _
", <BR>Manufacturer: " & objWEBM.Manufacturer & _
", <BR>Status: " & objWEBM.Status & "<BR></LI>"
Next
Response.write "</UL>"
'Clean up
Set objLocator = Nothing
Set objService = Nothing
Set objWEBMCol = Nothing
Set objWEBM = Nothing
End Function
Call ShowNetworkClients("vComputerName")
%>
**********************************************************************
**********************************************************************
Tip of the Day!
By Srinivasa Sivakumar
List all the Disk Partition information from ASP:
<%
Function ShowDiskPartition(vComputerName)
Dim objLocator, objService, objWEBMCol, objWEBM
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
'Establish a connection to WMI
If isEmpty(vComputerName) = True then
Set objService = objLocator.ConnectServer
Else
Set objService = objLocator.ConnectServer(vComputerName)
End If
'Get the Webm Service object
Set objWEBMCol = objService.InstancesOf("Win32_DiskPartition")
Response.write "<H2> Disk Partition:</H2><HR><UL>"
'Enumerate
For Each objWEBM in objWEBMCol
Response.write "<LI>Availability: " & objWEBM.Availability & _
", <BR>Caption: " & objWEBM.Caption & _
", <BR>Block Size: " & objWEBM.BlockSize & _
", <BR>Bootable: " & objWEBM.Bootable & _
", <BR>Boot Partition: " & objWEBM.BootPartition & _
", <BR>Description: " & objWEBM.Description & _
", <BR>Device ID: " & objWEBM.DeviceID & _
", <BR>Disk Index: " & objWEBM.DiskIndex & _
", <BR>Hidden Sectors: " & objWEBM.HiddenSectors & _
", <BR>Number Of Blocks: " & objWEBM.NumberOfBlocks & _
", <BR>Plug and Play device identifier: " & objWEBM.PNPDeviceID & _
", <BR>Power Management Supported: " & objWEBM.PowerManagementSupported & _
", <BR>Primary Partition: " & objWEBM.PrimaryPartition & _
", <BR>Size: " & objWEBM.Size & _
", <BR>Starting Offset: " & objWEBM.StartingOffset & _
", <BR>Status: " & objWEBM.Status & _
", <BR>System Name: " & objWEBM.SystemName & _
", <BR>Type: " & objWEBM.Type & "<BR></LI>"
Next
Response.write "</UL>"
'Clean up
Set objLocator = Nothing
Set objService = Nothing
Set objWEBMCol = Nothing
Set objWEBM = Nothing
End Function
Call ShowDiskPartition("vComputerName")
%>
Note: Pass the computer name as the parameter. An empty string will work when you are accessing
the local
computer.
**********************************************************************
**********************************************************************
Tip of the Day!
By Srinivasa Sivakumar
List all the NT Base Services from ASP:
<%
Function ShowNTBaseServices(vComputerName)
Dim objLocator, objService, objWEBMCol, objWEBM
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
'Establish a connection to WMI
If isEmpty(vServerName) = True then
Set objService = objLocator.ConnectServer
Else
Set objService = objLocator.ConnectServer(vComputerName)
End If
'Get the Webm Service object
Set objWEBMCol = objService.InstancesOf("Win32_BaseService")
Response.write "<H2>NT Base Services:</H2><HR><UL>"
'Enumerate
For Each objWEBM in objWEBMCol
Response.write "<LI>Caption: " & objWEBM.Caption & _
", <BR>Can be paused: " & objWEBM.AcceptPause & _
", <BR>Can be Stopped: " & objWEBM.AcceptStop & _
", <BR>Description: " & objWEBM.Description & _
", <BR>DisplayName: " & objWEBM.DisplayName & _
", <BR>Path: " & objWEBM.PathName & _
", <BR>Service Type: " & objWEBM.ServiceType & _
", <BR>Running: " & objWEBM.Started & _
", <BR>Start Mode: " & objWEBM.StartMode & _
", <BR>State: " & objWEBM.State & _
", <BR>Status: " & objWEBM.Status & "<BR></LI>"
Next
Response.write "</UL>"
'Clean up
Set objLocator = Nothing
Set objService = Nothing
Set objWEBMCol = Nothing
Set objWEBM = Nothing
End Function
Call ShowNTBaseServices("vComputerName")
%>
Note: Pass the computer name as the parameter. An empty string will work when you are accessing
the local
computer.
**********************************************************************
**********************************************************************
Tip of the Day!
By Srinivasa Sivakumar
List all network clients installed from ASP:
<%
Function ShowNetworkClients(vComputerName)
Dim objLocator, objService, objWEBMCol, objWEBM
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
'Establish a connection to WMI
If isEmpty(vComputerName) = True then
Set objService = objLocator.ConnectServer
Else
Set objService = objLocator.ConnectServer(vComputerName)
End If
'Get the Webm Service object
Set objWEBMCol = objService.InstancesOf("Win32_NetworkClient")
Response.write "<H2> Network Clients Installed:</H2><HR><UL>"
'Enumerate
For Each objWEBM in objWEBMCol
Response.write "<LI>Name: " & objWEBM.Name & _
", <BR>Caption: " & objWEBM.Caption & _
", <BR>Description: " & objWEBM.Description & _
", <BR>Manufacturer: " & objWEBM.Manufacturer & _
", <BR>Status: " & objWEBM.Status & "<BR></LI>"
Next
Response.write "</UL>"
'Clean up
Set objLocator = Nothing
Set objService = Nothing
Set objWEBMCol = Nothing
Set objWEBM = Nothing
End Function
Call ShowNetworkClients("vComputerName")
%>
**********************************************************************
**********************************************************************
Tip of the Day!
By Srinivasa Sivakumar
List the Windows NT Event Logs from ASP:
<%
Function ShowNTLogEvent(vComputerName, vLogType)
Dim objLocator, objService, objWEBMCol, objWEBM, vType
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
'Establish a connection to WMI
If isEmpty(vComputerName) = True then
Set objService = objLocator.ConnectServer
Else
Set objService = objLocator.ConnectServer(vComputerName)
End If
'Get the Webm Service object
Set objWEBMCol = objService.ExecQuery("SELECT * FROM " & _
" win32_NTLogEvent WHERE LogFile='" & vLogType & "'")
Response.write "<H2> Windows NT Event Log:</H2><HR><UL>"
'Enumerate
For Each objWEBM in objWEBMCol
vType = ""
if objWEBM.Type = "1" then
vType = "Error!"
elseif objWEBM.Type = "2" then
vType = "Warning!"
elseif objWEBM.Type = "4" then
vType = "Information"
elseif objWEBM.Type = "8" then
vType = "Audit success"
elseif objWEBM.Type = "16" then
vType = "Audit failure"
end if
Response.write "<LI>Category: " & objWEBM.Category & _
", <BR>Computer Name: " & objWEBM.ComputerName & _
", <BR>Source Name: " & objWEBM.SourceName & _
", <BR>Event Code: " & objWEBM.EventCode & _
", <BR>Type: " & vType & _
", <BR>Message: " & objWEBM.Message & _
", <BR>User: " & objWEBM.User & "<BR></LI>"
Next
Response.write "</UL>"
'Clean up
Set objLocator = Nothing
Set objService = Nothing
Set objWEBMCol = Nothing
Set objWEBM = Nothing
End Function
Call ShowNTLogEvent("vComputerName", "vLogType")
%>
Note: Pass the computer name as the parameter. An empty string will work when you are accessing
the local
computer. VLogType value can be "Application", "Security" or "System".
**********************************************************************
**********************************************************************
Tip of the Day!
By Srinivasa Sivakumar
Get Windows Desktop settings from ASP:
<%
Function ShowDesktopSettings(vComputerName)
Dim objLocator, objService, objWEBMCol, objWEBM
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
'Establish a connection to WMI
If isEmpty(vServerName) = True then
Set objService = objLocator.ConnectServer
Else
Set objService = objLocator.ConnectServer(vComputerName)
End If
'Get the Webm Service object
Set objWEBMCol = objService.InstancesOf("Win32_Desktop")
Response.write "<H2>Windows Desktop Settings:</H2><HR><UL>"
'Enumerate
For Each objWEBM in objWEBMCol
Response.write "<LI>Border Width: " & objWEBM.BorderWidth & _
", <BR>Fast task switching with ALT + TAB: " & objWEBM.CoolSwitch & _
", <BR>Cursor Blink Rate: " & objWEBM.CursorBlinkRate & _
", <BR>Drag Full Windows: " & objWEBM.DragFullWindows & _
", <BR>Grid Granularity: " & objWEBM.GridGranularity & _
", <BR>Icon Spacing: " & objWEBM.IconSpacing & _
", <BR>Icon Title Font Name: " & objWEBM.IconTitleFaceName & _
", <BR>Icon Title Size: " & objWEBM.IconTitleSize & _
", <BR>Icon Title Wrap: " & objWEBM.IconTitleWrap & _
", <BR>Desktop Pattern: " & objWEBM.Pattern & _
", <BR>Active Screen Saver: " & objWEBM.ScreenSaverActive & _
", <BR>Password Enabled Screen Saver: " & objWEBM.ScreenSaverSecure & _
", <BR>Screen Saver Timeout: " & objWEBM.ScreenSaverTimeout & _
", <BR>Wall Paper Name: " & objWEBM.Wallpaper & _
", <BR>Wall Paper Stretched: " & objWEBM.WallpaperStretched & _
", <BR>Wall Paper Tiled: " & objWEBM.WallpaperTiled & "<BR></LI>"
Next
Response.write "</UL>"
'Clean up
Set objLocator = Nothing
Set objService = Nothing
Set objWEBMCol = Nothing
Set objWEBM = Nothing
End Function
Call ShowDesktopSettings("vComputerName")
%>
Note: Pass the computer name as the parameter. An empty string will work when you are accessing
the local
computer.
**********************************************************************
**********************************************************************
Tip of the Day!
By Srinivasa Sivakumar
List all the Directory Information from ASP:
<%
Function ShowSystemProduct(vComputerName)
Dim objLocator, objService, objWEBMCol, objWEBM
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
'Establish a connection to WMI
If isEmpty(vComputerName) = True then
Set objService = objLocator.ConnectServer
Else
Set objService = objLocator.ConnectServer(vComputerName)
End If
'Get the Webm Service object
Set objWEBMCol = objService.InstancesOf("Win32_Directory")
Response.write "<H2>Directry Info:</H2><HR><UL>"
'Enumerate
For Each objWEBM in objWEBMCol
Response.write "<LI>Access Mask: " & objWEBM.AccessMask & _
", <BR>Caption: " & objWEBM.Caption & _
", <BR>Compressed File: " & objWEBM.Compressed & _
", <BR>Compression Method Used: " & objWEBM.CompressionMethod & _
", <BR>Creation Date: " & objWEBM.CreationDate & _
", <BR>Drive: " & objWEBM.Drive & _
", <BR>Encrypted File: " & objWEBM.Encrypted & _
", <BR>Encryption Method Used: " & objWEBM.EncryptionMethod & _
", <BR>File Name: " & objWEBM.FileName & _
", <BR>File Extension: " & objWEBM.Extension & _
", <BR>File Type: " & objWEBM.FileType & _
", <BR>Hidden File: " & objWEBM.Hidden & _
", <BR>Install Date: " & objWEBM.InstallDate & _
", <BR>File In Use Count: " & objWEBM.InUseCount & _
", <BR>File Last Accessed: " & objWEBM.LastAccessed & _
", <BR>File Last Modified: " & objWEBM.LastModified & _
", <BR>File Name with Path: " & objWEBM.Name & _
", <BR>File Status: " & objWEBM.Status & _
", <BR>System File: " & objWEBM.System & "<BR></LI>"
Next
Response.write "</UL>"
'Clean up
Set objLocator = Nothing
Set objService = Nothing
Set objWEBMCol = Nothing
Set objWEBM = Nothing
End Function
Call ShowSystemProduct("vComputerName")
%>
Note: Pass the computer name as the parameter. An empty string will work when you are accessing
the local
computer.
**********************************************************************
**********************************************************************
Tip of the Day!
By Srinivasa Sivakumar
List all Windows user group accounts from ASP:
<%
Function ShowWindowsUserGroupAccounts(vComputerName)
Dim objLocator, objService, objWEBMCol, objWEBM
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
'Establish a connection to WMI
If isEmpty(vComputerName) = True then
Set objService = objLocator.ConnectServer
Else
Set objService = objLocator.ConnectServer(vComputerName)
End If
'Get the Webm Service object
Set objWEBMCol = objService.InstancesOf("Win32_Group")
Response.write "<H2>Windows User Group Accounts:</H2><HR><UL>"
'Enumerate
For Each objWEBM in objWEBMCol
Response.write "<LI>Name: " & objWEBM.Name & _
", <BR>Caption: " & objWEBM.Caption & _
", <BR>Description: " & objWEBM.Description & _
", <BR>Domain: " & objWEBM.Domain & _
", <BR>Security identifier: " & objWEBM.SID & _
", <BR>Security identifier Type: " & objWEBM.SIDType & _
", <BR>Status: " & objWEBM.Status & "<BR></LI>"
Next
Response.write "</UL>"
'Clean up
Set objLocator = Nothing
Set objService = Nothing
Set objWEBMCol = Nothing
Set objWEBM = Nothing
End Function
Call ShowWindowsUserGroupAccounts("vComputerName")
%>
Note: Pass the computer name as the parameter. An empty string will work when you are accessing
the local
computer.
**********************************************************************
**********************************************************************
Tip of the Day!
By Srinivasa Sivakumar
List all Active Network Connections from ASP:
<%
Function ShowActiveNetworkConnections(vComputerName)
Dim objLocator, objService, objWEBMCol, objWEBM
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
'Establish a connection to WMI
If isEmpty(vComputerName) = True then
Set objService = objLocator.ConnectServer
Else
Set objService = objLocator.ConnectServer(vComputerName)
End If
'Get the Webm Service object
Set objWEBMCol = objService.InstancesOf("Win32_NetworkConnection")
Response.write "<H2>Active Network Connections:</H2><HR><UL>"
'Enumerate
For Each objWEBM in objWEBMCol
Response.write "<LI>Name: " & objWEBM.Name & _
", <BR>Caption: " & objWEBM.Caption & _
", <BR>Description: " & objWEBM.Description & _
", <BR>Access Mask: " & objWEBM.AccessMask & _
", <BR>Comments: " & objWEBM.Comment & _
", <BR>Connection State: " & objWEBM.ConnectionState & _
", <BR>Connection Type: " & objWEBM.ConnectionType & _
", <BR>Display Type: " & objWEBM.DisplayType & _
", <BR>Local Name: " & objWEBM.LocalName & _
", <BR>Provider Name: " & objWEBM.ProviderName & _
", <BR>Remote Name: " & objWEBM.RemoteName & _
", <BR>Remote Path: " & objWEBM.RemotePath & _
", <BR>Resource Type: " & objWEBM.ResourceType & _
", <BR>User Name: " & objWEBM.UserName & _
", <BR>Status: " & objWEBM.Status & "<BR></LI>"
Next
Response.write "</UL>"
'Clean up
Set objLocator = Nothing
Set objService = Nothing
Set objWEBMCol = Nothing
Set objWEBM = Nothing
End Function
Call ShowActiveNetworkConnections("vComputerName")
%>
Note: Pass the computer name as the parameter. An empty string will work when you are accessing
the local
computer.
**********************************************************************
**********************************************************************
Tip of the Day!
By Srinivasa Sivakumar
List all Network Protocols Installed from ASP:
<%
Function ShowNetworkProtocols(vComputerName)
Dim objLocator, objService, objWEBMCol, objWEBM
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
'Establish a connection to WMI
If isEmpty(vComputerName) = True then
Set objService = objLocator.ConnectServer
Else
Set objService = objLocator.ConnectServer(vComputerName)
End If
'Get the Webm Service object
Set objWEBMCol = objService.InstancesOf("Win32_NetworkProtocol")
Response.write "<H2>Network Protocols Installed:</H2><HR><UL>"
'Enumerate
For Each objWEBM in objWEBMCol
Response.write "<LI>Name: " & objWEBM.Name & _
", <BR>Caption: " & objWEBM.Caption & _
", <BR>Description: " & objWEBM.Description & _
", <BR>Connectionless Service: " & objWEBM.ConnectionlessService & _
", <BR>Guarantees Delivery: " & objWEBM.GuaranteesDelivery & _
", <BR>Guarantees Sequencing: " & objWEBM.GuaranteesSequencing & _
", <BR>Maximum Address Size: " & objWEBM.MaximumAddressSize & _
", <BR>Maximum Message Size: " & objWEBM.MaximumMessageSize & _
", <BR>Message Oriented: " & objWEBM.MessageOriented & _
", <BR>Minimum Address Size: " & objWEBM.MinimumAddressSize & _
", <BR>Pseudo Stream Oriented: " & objWEBM.PseudoStreamOriented & _
", <BR>Supports Broadcasting: " & objWEBM.SupportsBroadcasting & _
", <BR>Supports Connect Data: " & objWEBM.SupportsConnectData & _
", <BR>Supports Disconnect Data: " & objWEBM.SupportsDisconnectData & _
", <BR>Supports Encryption: " & objWEBM.SupportsEncryption & _
", <BR>Supports Expedited Data: " & objWEBM.SupportsExpeditedData & _
", <BR>Supports Fragmentation: " & objWEBM.SupportsFragmentation & _
", <BR>Supports Graceful Closing: " & objWEBM.SupportsGracefulClosing & _
", <BR>Supports Guaranteed Bandwidth: " & _
objWEBM.SupportsGuaranteedBandwidth & _
", <BR>Supports Multicasting: " & objWEBM.SupportsMulticasting & _
", <BR>Supports Quality of Service: " & objWEBM.SupportsQualityofService _
& "<BR></LI>"
Next
Response.write "</UL>"
'Clean up
Set objLocator = Nothing
Set objService = Nothing
Set objWEBMCol = Nothing
Set objWEBM = Nothing
End Function
Call ShowNetworkProtocols("vComputerName")
%>
Note: Pass the computer name as the parameter. An empty string will work when you are accessing
the local
computer.
**********************************************************************
**********************************************************************
Tip of the Day!
By Srinivasa Sivakumar
List all Scheduled Jobs in Windows Scheduler from ASP:
<%
Function ShowScheduledJobs(vComputerName)
Dim objLocator, objService, objWEBMCol, objWEBM
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
'Establish a connection to WMI
If isEmpty(vComputerName) = True then
Set objService = objLocator.ConnectServer
Else
Set objService = objLocator.ConnectServer(vComputerName)
End If
'Get the Webm Service object
Set objWEBMCol = objService.InstancesOf("Win32_ScheduledJob")
Response.write "<H2>Scheduled Jobs in Windows Scheduler:</H2><HR><UL>"
'Enumerate
For Each objWEBM in objWEBMCol
Response.write "<LI>Name: " & objWEBM.Name & _
", <BR>Caption: " & objWEBM.Caption & _
", <BR>Description: " & objWEBM.Description & _
", <BR>Command: " & objWEBM.Command & _
", <BR>Days Of Month: " & objWEBM.DaysOfMonth & _
", <BR>Days Of Week: " & objWEBM.DaysOfWeek & _
", <BR>Interact With Desktop: " & objWEBM.InteractWithDesktop & _
", <BR>Job ID: " & objWEBM.JobId & _
", <BR>Job Status: " & objWEBM.JobStatus & _
", <BR>Notify User: " & objWEBM.Notify & _
", <BR>Owner of the Job: " & objWEBM.Owner & _
", <BR>Priority: " & objWEBM.Priority & _
", <BR>Run Repeatedly: " & objWEBM.RunRepeatedly & _
", <BR>Status: " & objWEBM.Status & "<BR></LI>"
Next
Response.write "</UL>"
'Clean up
Set objLocator = Nothing
Set objService = Nothing
Set objWEBMCol = Nothing
Set objWEBM = Nothing
End Function
Call ShowScheduledJobs("vComputerName")
%>
Note: Pass the computer name as the parameter. An empty string will work when you are accessing
the local
computer. This ASP tip needs Basic or NTLM authentication for the virtual directory
where it has been hosted.
**********************************************************************
**********************************************************************
Tip of the Day!
By Srinivasa Sivakumar
List all Windows Network Login Profiles from ASP:
<%
Function ShowNetworkLoginProfiles(vComputerName)
Dim objLocator, objService, objWEBMCol, objWEBM
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
'Establish a connection to WMI
If isEmpty(vComputerName) = True then
Set objService = objLocator.ConnectServer
Else
Set objService = objLocator.ConnectServer(vComputerName)
End If
'Get the Webm Service object
Set objWEBMCol = objService.InstancesOf("Win32_NetworkLoginProfile")
Response.write "<H2> Windows Network Login Profiles:</H2><HR><UL>"
'Enumerate
For Each objWEBM in objWEBMCol
Response.write "<LI>Name: " & objWEBM.Name & _
", <BR>Caption: " & objWEBM.Caption & _
", <BR>Description: " & objWEBM.Description & _
", <BR>Authorization Flags: " & objWEBM.AuthorizationFlags & _
", <BR>Bad Password Count: " & objWEBM.BadPasswordCount & _
", <BR>Code Page: " & objWEBM.CodePage & _
", <BR>Full Name: " & objWEBM.FullName & _
", <BR>Home Directory: " & objWEBM.HomeDirectory & _
", <BR>Home Drive: " & objWEBM.HomeDirectoryDrive & _
", <BR>Account Expires: " & mid(objWEBM.AccountExpires,5,2) & "/" _
& mid(objWEBM.AccountExpires,7,2) & "/" & _
mid(objWEBM.AccountExpires,1,4) & _
", <BR>Last Logon: " & mid(objWEBM.LastLogon,5,2) & "/" _
& mid(objWEBM.LastLogon,7,2) & "/" & mid(objWEBM.LastLogon,1,4) & _
", <BR>Last Logoff: " & mid(objWEBM.LastLogoff,5,2) & "/" _
& mid(objWEBM.LastLogoff,7,2) & "/" & mid(objWEBM.LastLogoff,1,4) & _
", <BR>Number Of Logons: " & objWEBM.NumberOfLogons & _
", <BR>Logon Server Name: " & objWEBM.LogonServer & _
", <BR>Maximum Storage: " & objWEBM.MaximumStorage & _
", <BR>Password Expires: " & mid(objWEBM.PasswordExpires,5,2) _
& "/" & mid(objWEBM.PasswordExpires,7,2) & "/" & _
mid(objWEBM.PasswordExpires,1,4) & _
", <BR>User ID: " & objWEBM.UserId & _
", <BR>User Type: " & objWEBM.UserType & "<BR></LI>"
Next
Response.write "</UL>"
'Clean up
Set objLocator = Nothing
Set objService = Nothing
Set objWEBMCol = Nothing
Set objWEBM = Nothing
End Function
Call ShowNetworkLoginProfiles("vComputerName")
%>
Note: Pass the computer name as the parameter. An empty string will work when you are accessing
the local
computer. This ASP tip needs Basic or NTLM authentication for the virtual directory
where it has been hosted.
**********************************************************************
Tip of the Day!
By Srinivasa Sivakumar
List all Service Pack information from ASP:
<%
Function ShowServicePack(vComputerName)
Dim objLocator, objService, objWEBMCol, objWEBM
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
'Establish a connection to WMI
If isEmpty(vComputerName) = True then
Set objService = objLocator.ConnectServer
Else
Set objService = objLocator.ConnectServer(vComputerName)
End If
'Get the Webm Service object
Set objWEBMCol = objService.InstancesOf("Win32_QuickFixEngineering")
Response.write "<H2>Service Pack information:</H2><HR><UL>"
'Enumerate
For Each objWEBM in objWEBMCol
Response.write "<LI>Name: " & objWEBM.Name & _
", <BR>Caption: " & objWEBM.Caption & _
", <BR>Service Pack In Effect: " & objWEBM.ServicePackInEffect & _
", <BR>Installed On: " & objWEBM.InstalledOn & _
", <BR>Installed By: " & objWEBM.InstalledBy & _
", <BR>Fix ID: " & objWEBM.HotFixID & _
", <BR>Fix Comments: " & objWEBM.FixComments & _
", <BR>Status: " & objWEBM.Status & "<BR></LI>"
Next
Response.write "</UL>"
'Clean up
Set objLocator = Nothing
Set objService = Nothing
Set objWEBMCol = Nothing
Set objWEBM = Nothing
End Function
Call ShowServicePack("vComputerName")
%>
Note: Pass the computer name as the parameter. An empty string will work when you are accessing
the local
computer. This ASP tip needs Basic or NTLM authentication for the virtual directory
where it has been hosted.
**********************************************************************
**********************************************************************
Tip of the Day!
By Srinivasa Sivakumar
Schedule A New Job from ASP:
<%
Function ScheduleAJob(vComputerName, vCommand, vStartTime)
Dim objLocator, objService, objWEBMCol
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
'Establish a connection to WMI
If isEmpty(vComputerName) = True then
Set objService = objLocator.ConnectServer
Else
Set objService = objLocator.ConnectServer(vComputerName)
End If
'Get the Webm Service object
Set objWEBMCol = objService.Get("Win32_ScheduledJob")
'Check the object variable
If objWEBMCol Is Nothing Then
Response.write "<B>Unable to Schedule the job!</B>"
Else
'Schedule the job
objWEBMCol.Create Cstr(vCommand), vStartTime
End if
'Clean up
Set objLocator = Nothing
Set objService = Nothing
Set objWEBMCol = Nothing
End Function
Call ScheduleAJob("vComputerName", vCommand, vStartTime)
%>
Note: Pass the computer name as the parameter. An empty string will work when you are accessing
the local
computer. This ASP tip needs Basic or NTLM authentication for the virtual directory
where it has been hosted. The vCommand represents the task to be carried out. For example, if you
want do a
backup of your server by calling the backup.exe then vCommand will be "backup". The vStartTime
represents the
starting time of the task. WMI uses the date time in the following format:
YYYYMMDDHHMMSS.MMMMMM(+-)OOO
We only need time for this parameter. Therefore, all other information needs to be replaces with
*'s. A valid
"12:30 PM" can be transformed to "********123000.000000-***".
*************************************************************************************************
***********************88
By Srinivasa Sivakumar
Delete a Scheduled Job from ASP:
<%
Function ScheduleAJob(vComputerName, vJobID)
Dim objLocator, objService, objWEBMCol
Set objLocator = CreateObject("WbemScripting.SWbemLocator")
'Establish a connection to WMI
If isEmpty(vComputerName) = True then
Set objService = objLocator.ConnectServer
Else
Set objService = objLocator.ConnectServer(vComputerName)
End If
'Get the Webm Service object
Set objWEBMCol = objService.Get("Win32_ScheduledJob.JobID=" & vJobID)
'Check the object variable
If objWEBMCol Is Nothing Then
Response.write "<B>Unable find the Scheduled job!</B>"
Else
'Kill the Scheduled job
objWEBMCol.Delete
End if
'Clean up
Set objLocator = Nothing
Set objService = Nothing
Set objWEBMCol = Nothing
End Function
Call ScheduleAJob("vComputerName", vJobID)
%>
Note: Pass the computer name as the parameter. An empty string will work when you are accessing
the local
computer. This ASP tip needs Basic or NTLM authentication for the virtual directory
where it has been hosted. Pass the vJobID as a parameter to kill the job.
*************************************************************************************************
****************
**********************************************************************
Tip of the Day!
By Glen Little
It is easy to get the results of a SQL 2000 "FOR XML" query into a XMLDOM
object on an IIS server:
dim dom, cmd
set dom = Server.CreateObject("MSXML2.DOMDocument")
set cmd = Server.CreateObject("ADODB.Command")
cmd.ActiveConnection = "..." ' an existing connection
cmd.CommandText = "Select * from MyTable For XML Auto"
cmd.Properties("Output Stream") = dom
cmd.Execute , , adExecuteStream
set cmd = Nothing
The "dom" object now has an XML document that looks identical to what you
would see in SQL Query Analyzer for the same SQL query.
**********************************************************************
Tip of the Day!
By Matthew Reynolds
If you want to host multiple Web sites on the same IP address, use the "Host Headers" option.
This will prompt IIS to examine the headers of incoming requests and route them to the matching
Web site. When creating a new Web site, the Wizard will ask you if you want to set a host header.
If you want to retrofit existing sites, open the properties, change to the "Web Site" tab and
click "Advanced". Double-click on the first "Multiple identity" for the site and set the "Host
Header Name" value. Make sure that you have Internet Explorer 3.0/ Netscape Navigator 2.0 or
later versions of these browsers and an appropriate change in your name resolution system (DNS)
to recognize host name.
**********************************************************************
Tip of the Day!
By Alain Trottier
Scalable Vector Graphics (SVG) is a new language that will soon affect Web clients (i.e. our
screens). SVG is a new open source text-based language for describing two-dimensional graphical
objects in XML. SVG was developed by the World Wide Web Consortium (W3C). Sun, IBM, Adobe,
Microsoft and AOL/Netscape are members or the SVG proposal group. Adobe Systems already has a
plug-in (http://www.adobe.com/svg/viewer/install/main.html ) for Internet Explorer and Netscape.
Several key advantages of SVG are:
Scalable vector graphics - do not degrade upon panning and zooming which is ideal for charting,
mapping, and Web site navigation graphics.
Increased color accuracy - over 16 million colors which means what is seen on the screen will
look exactly the same when printed Compatibility with XML, HTML4, XHTML as well as conformance to
CSS, XSL, and the DOM - this means that SVG is extensible, styleable, scriptable, and integrates
easily.
**********************************************************************
Tip of the Day!
By Ian Vink
Often many search engines have indexed your site. If you move or rename a page in your ASP
application, you need to have that page re-direct to the new page. It's like having the post
office re-direct your mail.
Send the browser an HTTP header to do this:
<% Response.Redirect http://www.asptoday.com %>
**********************************************************************
**********************************************************************
Tip of the Day!
By Ian Vink
If you wish your HTML code to be output to the browser but not processed as HTML, set the
ContentType of the Response Object like this:
<% Response.ContentType = "text/plain" %>
Normally by default the ContentType is set to: text/HTML
**********************************************************************
Tip of the Day!
By Ian Vink
It's more efficient to declare objects only when they are needed and to use the <OBJECT> tag
instead of the Server.CreateObject() call.
Also keep in mind that since the <OBJECT> tag uses unique CLASSIDS this tends to mean that
version mis-matches are less common than with using Server.CreateObject(ProgID) because the
ProgID of a COM object doesn't have to change version after version.
**********************************************************************
Tip of the Day!
by Sandra Gopikrishna
In ASP (VBScript), use the constant vbCrLF to add line breaks in your string
variables:
example
<%
strString = "Hello" & vbCrLF & "There"
response.write(strString)
%>
The above piece of code produces the following output
Hello
There
**********************************************************************
Tip of the Day!
by Ian Vink
You can create your own HTTP headers with custom values, which are sent to the browser.
<% Response.AddHeader "ABC123", "(c) 2000 ADC123 corp" %>
This will send a new header with a name of "ABC123" and a value of "(c) 2000 ADC123 corp"
Because of HTTP guidelines, AddHeader calls must be before any HTML code and before any
response.write calls
**********************************************************************
Tip of the Day!
by Ian Vink
Instead of using Regsvr32.exe to register a COM object on your server and then calling it from
your ASP pages, drag and drop the COM object into your Microsoft Transaction Server (or COM+ in
Windows 2000)
This way if you need to update the COM object you don't have to re-boot the server each time.
Objects called outside of MTS or COM+ are locked by the server and can't be replaced by new
versions.
**********************************************************************
Tip of the Day!
by Ian Vink
Using standard conventions when designing your ASP code is important for
maintainability.
It's recommended that when you define a constant, use all upper case with
underscores to separate words.
<% Const MIN_SALES = 25 %>
**********************************************************************
Tip of the Day!
by Ian Vink
To improve performance and readability try to use code in larger sections,
**********************************************************************
Tip of the Day!
By Ian Vink
Although your ASP application may have mostly ASP pages, if there is no script on a page, then
don't give it an ASP extension. HTM extensions are handled faster than ASP because they don't
have to be processed.
**********************************************************************
Tip of the Day!
By Alain Trottier
What is XHTML? XHTML (eXtensible Hypertext Markup Language) is HTML that conforms to strict XML
rules. HTML has become sloppy. Current browsers
permit poorly coded pages. Browsers pay a performance price for fixing
things like improperly nested or unclosed tags. New browsers process XHTML faster than HTML. The
primary differences between XHTML and HTML are:
1. XHTML tags and attributes must be in lower case.
2. All tags must be closed.
3. <head> and <body> tags can't be left out.
4. All attribute values must have quotation marks.
5. A DTD declaration must be included at the top of the document.
a. <!DOCTYPE PUBLIC "-//W3C/DTD XHTML 1.0 STRICT//EN" "">
6. A reference to the XML namespace needs to be in the <html> element.
a. <html xmlns=http://www.w3.org/tr/xhtml1>
7. Tags must be properly nested.
8. The <title> element must be the first element in the head.
9. Attributes cannot be shortened or "minimized".
BAD HTML Example
<html><HEAD><TITLE>This is really bad</TITLE></HEAD>
<BODY>
<B>BAD HTML EXAMPLE<BR>
</BODY>
<html>
XHTML Equivalent
<?xml version="1.0" encoding="UTF-9"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="eng">
<head>
<title>Good XHTML</title>
</head>
<body>
<b>Good XHTML example</b><br/>
</body>
</html>
**********************************************************************
Tip of the Day!
by Sandra Gopikrishna
When we try to instantiate an ActiveX exe from asp 2.0 page it will be
creating the following error
Server object error 'ASP 0196'
Cannot launch out of process component
but the same activex exe when instantiated from asp 3.0 page runs normally
this is because of the fact that out of process components are disabled by
default in asp 2.0, while they are enabled by default in asp 3.0
**********************************************************************
Tip of the Day!
by Ian Vink
To make you selections more noticeable, add a HOVER attibute to your Anchor tag in your
Casscading Style Sheet.
When the usr moves the mouse over the link to your ASP or HTML page, it will light up. No
scripting needed either!
A:hover
{
COLOR: RED;
TEXT-DECORATION: underline
}
**********************************************************************
Tip of the Day!
by Ian Vink
To improve the maintainability of your code, use the MapPath method of the
server object instead of hard coding paths. When you have to move your ASP
code to a new server, MapPath will take care of finding out where you are on
the server.
There is a small performance hit as each time you use MapPath it has to hit
the server for the information, but if you use it once at the top of the ASP
script and save the information into a variable it won't be too much of a
hit.
***********************************************************************
Tip of the Day!
by Ian Vink
To improve readability of your code begin each object name in COM objects
you create with a verb. Use Initial capitalization for words with in the
objects name.
For example,
An object called "Sales" might have these methods
AddNewCustomer
DeleteOrder
DeleteCustomer
**********************************************************************
Tip of the Day!
by Ian Vink
When you need to debug a variable, you can print it with Msgbox in the OnLoad event of the
Window.
Server Side:
<%
dim MyVar
MrVar = "BibleOcean.com"
%>
Client Side:
<script language=vbscript>
sub window_onload()
msgbox "<%=MyVar%>"
end sub
</script>
**********************************************************************
Tip of the Day!
by Ian Vink
In IE you can use conditional comments to hide code from down level (old) browsers.
<!-- [if gte IE 5] >
<XML>
<Some XML Data Island not seen by old browsers>
</XML>
<! [endif]-->
The first and last line indicate the IF / END IF pair.
**********************************************************************
Tip of the Day!
by Sandra Gopikrishna
1.HTML provides us with a special button by name 'Reset' using which the values present in the
input fields contained in a form are Reset to their initial values. The use of Reset button is a
bit tricky. Reset button reset the values of input controls to the value specified in their
'Value' attribute only. The following example makes the above concept clear
resesttest.html
---------------
<html>
<head>
<title> Testing ASP Reset Functionality </title>
<script language = "javaScript">
function fn_callme() {
document.form1.txt1.value = "345";
document.form1.txt2.value = "789";
}
</script>
</head>
<body onLoad = "fn_callme()">
<form name = "form1">
<input type = "text" name = "txt1" value = "123" ><br>
<!-- value attribute not specified for txt2 and by default it is assumed as empty string -->
<input type = "text" name = "txt2" ><br>
<input type = "reset" Value = "reset">
</form>
</body>
</html>
Invoke the above example in a browser try changing the values of textboxes and click reset after
that. you will be surprised to see that textboxes are rest to values "123" and "" respectively,
which are the values specified in value attribrte of textbox
**********************************************************************
Tip of the Day!
by Sandra Gopikrishna
Both ASP and ASP+ can coexist and run on the same server . ASP+ files are
identified with .aspx extension, whereas asp files are identified by .asp
extension.
**********************************************************************
Tip of the Day!
by Ian Vink
In the Internet Services Manager enable the "Enable Session State"
directive.
You should then save resources by turning off session state information for
pages that don't use it with this directive at the top of the ASP script.
<%@ ENABLESESSIONSTATE = False %>
**********************************************************************
Tip of the Day!
by Sandra Gopikrishna
1.ASP+ is the "Next Generation" of Active Server Page technology.
2.ASP+ supports three languages, They are VB, C# (C-Sharp) and JScript.
3.The code of ASP+ is compiled.
4.The existing ASP web applications can now reside side by side along With
ASP+ applications
**********************************************************************
Tip of the Day!
by Sandra Gopikrishna
Sometimes it is very convenient to upload a text file and load it into your database using ASP.
The following piece of ASP code demonstrates the method of loading text file (having data
delimited by space) Into A Database
<%
set conn = server.createobject("ADODB.CONNECTION")
conn.open "DSNNAME" , "USERID" , "PASSWORD"
set rs=server.createobject("adodb.recordset")
rs.open "WelcomeSV",conn,3,3
Set fs = CreateObject("Scripting.FileSystemObject")
filename=server.mappath("/attitude/geo/sv.txt")
Set readfile=fs.OpenTextFile(filename,1,False)
Do while not readfile.atendofstream
on error resume next
Text=readfile.readline
MemberInfo = split(Text, " ", 3)
rs.addnew
rs("member")=MemberInfo(0)
rs("email")=MemberInfo(1)
rs("site")=MemberInfo(2)
rs.update
count=count+1
loop
readfile.close
set readfile=nothing
set fs=nothing
rs.close
set rs=nothing
conn.close
set conn=nothing
response.write "<center><b>" & Count & " records were loaded</b></center>"
%>
**********************************************************************
Tip of the Day!
by Ian Vink
When you are converting Visual Basic applications to be run on the web,
convert them to DLLs and then call them with the server.creatobject() call.
DLLs are much faster than Asp script.
**********************************************************************
Tip of the Day!
by Ian Vink
The Dictionary object is the fastest and most resource friendly way of
looking up arbitrary key/data pairs. This is because you specify a key
(which is indexed by the Dictionary Object) instead of linearly traversing
the data looking for the item you wish.
**********************************************************************
Tip of the Day!
by Sandra Gopikrishna
The capacity of the overall website can be measured by using one of the
following tools provided by Microsoft
1.InetMonitor
2.WebCapacityAnalysisTool(WCAT)
of these two tools it is better to stick to InetMonitor as it is very
flexible and Easy to use.
**********************************************************************
Tip of the Day!
by Sandra Gopikrishna
Sometimes while accessing .mdb (Access Database files ) from ASP we are bound
to get the following error. "[Microsoft][ODBC Microsoft Access 97 Driver]
Operation must use an updatable query. " Knowing the cause of this error
can help us to fix this problem. Some causes for the problems and the solutions
are listed below
1. Ensure that the mdb file is not readonly.
2. Ensure that the directory containing the mdb File has both read and write
permissions , because when ever we access mdb file it creates a
corresponding file with .ldb extension in the same directory containing the
mdb fle. If the directory containing the mdb file doesnt have write
permission it can't create the corresponding ldb file required for database
updating, insertion and delete, which leads to the above problem
3. Ensure that the fired SQL query is not violating Referential integrity
constraints.
**********************************************************************
Tip of the Day!
by Ian Vink
If you have to check what the value of a variable is, it is much easier to
read a script that is written with Select...CASE statements than numerous
IF..THEN..ELSE statements.
[%
If Customer = "Nabil" then Price = 50
If Customer = "Ian" then Price = 34
If Customer = "Omid" then Price = 76
If Customer = "Runa" then Price = 12
If Customer = "Blythe" then Price = 33
%]
is much harder to read than this example:
[%
Select Case Customer
Case "Nabil"
Price = 50
Case "Ian"
Price = 34
Case "Omid"
Price = 76
Case "Runa"
Price = 12
Case "Blythe"
Price = 33
End select
%]
**********************************************************************
Tip of the Day!
by Ian Vink
If you have to fill a string with multiple characters, it's more elegant and easy to read if you
use the STRING() command than a for next loop.
[% LongA = STRING(50,"A") %]
Rather than:
[%
for x = 1 to 50
LongA = LongA & "A"
Next
%]
**********************************************************************
Tip of the Day!
by Sandra Gopikrishna
In an ASP Page while connecting to database employing a Connection object of ADO
we come across a property called Provider. When we set the connectionString
property or connectionstring argument of connection object's open method the
provider property should be set.
It is important to know the Value of the provider property of a connection
object
for different databases
MSDASQL for ODBC
Microsoft.Jet.Oledb.4.0 for access
SQLOLEDB for SQLServer
MSDAORA for Oracle
**********************************************************************
Tip of the Day!
by Ian Vink
<p>When you are designing the structure of your ASP application, the main root
should have at least two files.
<p>The Default.ASP (or Default.htm if the main page has no script) and the
Global.ASA, which runs when a user coming to your site starts
your application.
**********************************************************************
Tip of the Day!
by Ian Vink
<p>If you try to create out of Process references on your server with the
Server.CreateObject method, you will have to set the registry key
"AllowOutOfProcCmpnts" to allow In Process references to be created.
<p>Otherwise you'll get the error:
<p>"Server object error 'ASP 0196'
<p>Only InProc server components should be used. If you want to use LocalServer
components, you must set the AllowOutOfProcCmpnts registry setting. Please
consult the readme file for important considerations. "
<p>To change this setting to allow Out of Process objects to be created, run
the RegEdit.exe tool then drill down to:
<p>HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W3SVC\ASP\Parameters
<p>And set AllowOutOfProcCmpnts = 1
<p>This is off by default (=0).
**********************************************************************
Tip of the Day!
by Sandra Gopikrishna
<p>Using server side comments prevents the end users of ASP Pages from viewing
them , where as HTML Comments can be viewed by any user. So if we want the
comments to be seen by developers of an ASP page alone. It is advisible to go
for server side comments
<p>[] denotes <>
<p>Different ways of commenting in ASP Page
<br>----------------------------------------
<p>[%
<br>'this is a server side comment in vbscript
<br>%]
<p>[html]
<br>[body]
<br>[!--
<br>this is html comment
<p>--]
<br>[/body]
<br>[/html]
**********************************************************************
Tip of the Day!
by Sandra Gopikrishna
<p>In ASP+ employing Visual Basic WHILE loops end with 'End While'. It should
be noted that while loop ends with wend in ASP. So the above pitfall should
be avoided in porting an web application fom ASP to ASP+.
<p>The syntax for while loop in ASP+ is as follows
<p>while (boolean expression)
<br>' body of while loop
<br>end while
**********************************************************************
Tip of the Day!
by Ian Vink
Using simple DATE(), ISDATE() and CDATE() functions you can write a birth date checker. ISDATE()
checks to see if it's a valid date, while CDATE()converts the text into date format.
<%
Dim strMsg
If IsDate(Request.Form("UserBirthDate")) then
If Cdate(Request.Form("BirthDate")) <= Date then
strMsg = "Valid Birthdate"
Else
strMsg = "Please enter a birth date that is before today."
End If
Else
strMsg = "What you entered is not a valid date"
End If
Response.write strMsg
%>
**********************************************************************
Tip of the Day!
by Ian Vink
To improve performance and processing time of your ASP script, remove blank lines from your
scripts and HTML, except those between lines of code for the purpose of readability.
**********************************************************************