6 Eylül 2007 Perşembe

Asp Report Maker



  • Detail and Summary Report
  • Crosstab Report
  • Simple Charts
  • Advanced Security
  • Export to HTML/Excel/Word
  • Custom View
  • Customizable Template
  • Database Synchronization

demo



Asp XmlMaker



  • Field as Element/Attribute
  • Filtering and Sorting
  • Master/Detail Data
  • Field Value Formatting
  • Null Value Handling
  • Custom View
  • Customizable Template
  • Template Extensions
  • Database Synchronization

demo


26 Ağustos 2007 Pazar

Asp express 5.0


  • ASP Express allows you the extreme flexibility of an HTML text editor, while giving you the automation of a great ASP and ASP.Net text editor. Just look at some of the features:ASP Features:Basic Structures, like:SelectIf-ThenDo-WhileFor/Next
  • ADO Connection Assistant
  • Here's one of the best ASP or ASP.Net additions to hit an editor in a long time.Automatically insert all the information for an ADO Connection with very little work at all. Just insert your variable names for Connection, Recordset, DSN & SQL Select & Insert Statements. Then - for the best part of all - the SQL Select & Insert Statement Assistants - use your local database copy to easily assemble your SQL Select or Insert Statements!
  • SQL Builder Assistant(works with MS Access AND SQL Server 7/2000)
  • Create complex SQL statements to use with your ADO connection - both SELECT (including Inner Join) & INSERT statements. All your tables & fields are automatically accessible from pull-down menus, along with all the variable names you created on the page!Once you've done these short steps, voila - your ADO connection and your basic SQL statement is inserted and you didn't even break a sweat!(For direct SQL Server utilization, SQL tools must be installed on your development computer, like Enterprise Mgr/Client Network Utility) You can even choose to automatically insert the output in an HTML table or a Select List if you want!
  • Email Asstant
  • Easily create an ASP document using CDO to do your email jobs
  • Automatic FORM CODE GENERATOR
  • Choose your MS Access or SQL Server 7/200 database and table - ASP Express automatically generates the HTML for the input form!Choose between regular form format, or ASP.Net format!
  • The Express Toolbox
  • One tab lists all your commonly used ASP, ASP.Net VBScript , Javascript, & HTML tags and Assistants; one tab allows you to have a listing of your local files, and one tab allows for opening and saving your files web site files directly from the File Server using FTP
  • DataServer Window
  • Keep your data connections handy during ASP Express sessions - easily see which tables/fields are in the database and much more!
  • Greatly Improved FTP Capabilites - now FTP'ing of files is easier than ever!
  • Express Menus
  • Auto/Pop-up Completion for common ASP syntax such as Response, Request, & Server. Soon - even more (Connection, Recordset, FilesystemObject)
  • Global ASA Template creation
  • Simple Key Strokes for opening & closing ASP scriptCode Librarian stocked with many code snippets - allows you to build your own often-used code snippet library!
  • ASP Hit Counter Assistant
  • Make any HTML tag phrase 'Response.Write' - ready - highlight and convert your HTML into a Response.Write statement!Go To Line Number FeatureTurn WordWrapping on or off as needed .A 'REQUEST' Assistant for easily adding Request.Form & Request.QueryString Variables & Form Field Text Box Input Names, along with Server Variables in a pull down list!
  • An Easy RESPONSE Assistant for easily adding Response.Write statements!
    Seamlessly add include statements, browsing for the files
  • Easily Drag & Drop between ASP Express & other applications
  • When you format your HTML text - it stays highlighted to more easily add other HTML formatting or links to existing text
  • Easily create an HTML Table from Excel or Access data pasted into ASP Express - with a simple double-click!
  • Full Search & Replace within open documents or even entire subdirectories!

45 days shareware download


11 Ağustos 2007 Cumartesi

Add or Subtract a number of Business days from a Date

' Note that it doesn't take Christmas, Easter and
' other holidays into account

Function BusinessDateAdd(ByVal days As Long, ByVal StartDate As Date, _
Optional ByVal SaturdayIsHoliday As Boolean = True) As Date
Do While days
' increment or decrement the date
StartDate = StartDate + Sgn(days)
' check that it is a week day
If Weekday(StartDate) <> vbSunday And (Weekday(StartDate) <> vbSaturday _
Or Not SaturdayIsHoliday) Then
' days becomes closer to zero
days = days - Sgn(days)
End If
Loop
BusinessDateAdd = StartDate
End Function


Pagination in ASP

'***************************************
'
' *
' iNumPerPage is the number of items to
' display on each page
' sURL is the page to put with the link
' , sQuerystring is additional qs stuff
' adodbConnection, adodbCommand, sTable
' are all for the table to get row count from. *
' *
' Print out the numbers (if any) betwee
' n the "previous" and "next" buttons
' It'll act like this (current # is in
' bold):
' 1 2 3 4 5 6 7 8 9 <b>10</b> >> next
' previous << <b>11</b> 12 13 14 15 16 17 18 *
' *
'' ****************************************

Sub PrintRecordsetNav( iNumPerPage, adodbConnection, adodbCommand, sTable, sURL, sQuerystring )

Dim iTtlNumItems, iDBLoc, sSqlTemp, iTtlTemp
Dim iDBLocTemp, sURLBeg, iA, iB, x, iTemp, rsObj

iDBLoc = CInt(Request("iDBLoc"))
iTtlNumItems = CInt(Request("iTtlNumItems"))
' Get ttl num of items from the database if it's Not already In the QueryString
If (iTtlNumItems = 0) Then
Set rsObj = Server.CreateObject("ADODB.Recordset")
sSqlTemp = "SELECT COUNT(*) FROM " & sTable
adodbCommand.CommandText = sSqlTemp
rsObj.Open adodbCommand
If Not(rsObj.EOF) Then
iTtlNumItems = rsObj(0)
End If
rsObj.Close
Set rsObj = Nothing
End If
iTtlTemp = iTtlNumItems \ iNumPerPage ' this is the number of numbers overall (use the "\" To return int)
iDBLocTemp = iDBLoc \ iNumPerPage ' this is which number we are currently On (use the "\" To return int)
If (sQuerystring <> "") Then
sURLBeg = "<A href = """ & sURL & "?" & sQuerystring & "&iTtlNumItems=" & iTtlNumItems & "&iDBLoc="
Else
sURLBeg = "<A href = """ & sURL & "?iTtlNumItems=" & iTtlNumItems & "&iDBLoc="
End If

'***** BEGIN DISPLAY *****
' Print the "Previous"
If (iDBLoc <> 0) Then
Response.Write sURLBeg & (iDBLoc - iNumPerPage) & """>Previous</A> "
End If
' Print the <<
If (iDBLocTemp >= iNumPerPage) Then
Response.Write sURLBeg & (( iDBLocTemp \ iNumPerPage ) * iNumPerPage ^ 2) - (iNumPerPage * 9) & """><<</A> "
End If

' Print the numbers in between. Print them out in sets of 10.
iA = ( iDBLocTemp \ iNumPerPage ) * iNumPerPage
iB = ( iDBLocTemp \ iNumPerPage ) * iNumPerPage + iNumPerPage
For x = iA To iB
iTemp = (x * iNumPerPage)
If (iTemp < iTtlNumItems) Then ' takes care of extra numbers after the overall final number
If (iDBLoc = iTemp) Then
Response.Write " <B>[" & x+1 & "]</B>"
Else
Response.Write " " & sURLBeg & (x * iNumPerPage) & """>" & x+1 & "</A>"
End If
Else
Exit For
End If
Next

' Print the >>
If (iTtlTemp > iDBLocTemp) Then
If ((iDBLocTemp + iNumPerPage) <= iTtlTemp) Then
Response.Write " " & sURLBeg & (( iDBLocTemp \ iNumPerPage ) * iNumPerPage + iNumPerPage ) * iNumPerPage & """>>></A> "
End If
End If
' Print the "Next"
If ((iDBLoc + iNumPerPage) < iTtlNumItems) Then
Response.Write " " & sURLBeg & (iDBLoc + iNumPerPage) & """>Next</A>"
End If
'***** End DISPLAY *****

End Sub


Calculate the Time to Download Files

<%
Function DownloadTime(intFileSize, strModemType)
Dim TimeInSeconds, ModemSpeed, strDownloadTime, AppendString
Dim intYears, intWeeks, intDays
Dim intHours, intMinutes, intSeconds
intYears = 0
intWeeks = 0
intDays = 0
intHours = 0
intMinutes = 0
intSeconds = 0
strDownloadTime = ""
Select Case strModemType
Case "Cable"
ModemSpeed = 400000
Case "56kbps"
ModemSpeed = 7000
Case "33.6kbps"
ModemSpeed = 4200
Case "28.8kbps"
ModemSpeed = 3600
End Select
TimeInSeconds = int(intFileSize / ModemSpeed)
'year maths added 1/4 of a day. 1 exact orbit of the sub is 365.25 days.
If (Int(TimeInSeconds / 31471200) <> 0) Then intYears = Int(TimeInSeconds / 31449600)
If ((Int(TimeInSeconds / 604800) Mod 52) <> 0) Then intWeeks = Int(TimeInSeconds / 604800) Mod 52
If ((Int(TimeInSeconds / 86400) Mod 7) <> 0) Then intDays = Int(TimeInSeconds / 86400) Mod 7
If TimeInSeconds >= 3600 Then intHours = Int(TimeInSeconds / 3600) Mod 24
If TimeInSeconds >= 60 Then intMinutes = Int(TimeInSeconds / 60) Mod 60
If TimeInSeconds >= 0 Then intSeconds = Int(TimeInSeconds) Mod 60
If intYears <> 0 Then
If intYears = 1 Then AppendString = "" Else AppendString = "s"
strDownloadTime = strDownloadTime & intYears & " year" & AppendString & ", "
End If
If intWeeks <> 0 Then
If intWeeks = 1 Then AppendString = "" Else AppendString = "s"
strDownloadTime = strDownloadTime & intWeeks & " week" & AppendString & ", "
End If
If intDays <> 0 Then
If intDays = 1 Then AppendString = "" Else AppendString = "s"
strDownloadTime = strDownloadTime & intDays & " day" & AppendString & ", "
End If
If intHours <> 0 Then
If intHours = 1 Then AppendString = "" Else AppendString = "s"
strDownloadTime = strDownloadTime & intHours & " hour" & AppendString & ", "
End If
If intMinutes <> 0 Then
If intMinutes = 1 Then AppendString = "" Else AppendString = "s"
strDownloadTime = strDownloadTime & intMinutes & " minute" & AppendString
End If
If ((intYears = 0) And (intWeeks = 0) And (intDays = 0) And (intHours = 0)) Then
If intSeconds = 1 Then AppendString = "" Else AppendString = "s"
If intMinutes > 0 Then
strDownloadTime = strDownloadTime & ", " & intSeconds & " second" & AppendString
Else
strDownloadTime = strDownloadTime & intSeconds & " second" & AppendString
End If
End If
DownloadTime = strDownloadTime
End Function
%>
<html>
<body>
It is going to take about
<%=DownloadTime(123456,Cable)%> to download this file.
</body>
</html>


How to Create Bar Charts

<%
Sub ShowChart(ByRef aValues, ByRef aLabels, ByRef strTitle, ByRef strXAxisLabel, ByRef strYAxisLabel)
Const gr_WIDTH = 450
Const gr_HEIGHT = 250
Const gr_BORDER = 5
Const gr_SPACER = 2
Const tbl_BORDER = 0
iMaxValue = 0
For I = 0 To UBound(aValues)
If iMaxValue < aValues(I) Then iMaxValue = aValues(I)
Next
iBarWidth = (gr_WIDTH \ (UBound(aValues) + 1)) - gr_SPACER
'NOTE: Each of the images you see in this code are just 1 pixel by 1 pixel
'wide, but we make them in different colors for the chart, and then
'stretch them to the size that we need them with the code below:
Response.Write"<table border="&tbl_BORDER&" cellspacing=0 cellpadding=0>"&_
"<tr><td colspan=3 align=center><h2>"&strTitle&"</h2></td></tr>"&_
"<tr>"&_
"<td valign=center><b>"&strYAxisLabel&"</td>"&_
"<td valign=top>"&_
"<table border="&tbl_BORDER&" cellspacing=0 cellpadding=0>"&_
"<tr>"&_
"<td rowspan=2><img src=""images/spacer.gif"" border=0 width=1 height="&gr_HEIGHT&"></td>"&_
"<td valign=top align=right>"&iMaxValue&" </td>"&_
"</tr>"&_
"<tr><td valign=bottom align=right>. </td></tr>"&_
"</table>"&_
"</td>"&_
"<td>"&_
"<table border="&tbl_BORDER&" cellspacing=0 cellpadding=0>"&_
"<tr>"&_
"<td valign=bottom><img src=""images/spacer_black.gif"" border=0 width="&gr_BORDER&" height="&gr_HEIGHT&"></td>"
For I = 0 To UBound(aValues)
iBarHeight = Int((aValues(I) / iMaxValue) * gr_HEIGHT)
If iBarHeight = 0 Then iBarHeight = 1
Response.Write"<td valign=bottom><img src=""images/spacer.gif"" border=0 width="&gr_SPACER&" height=1></td>"&_
"<td valign=bottom><img src=""images/spacer_red.gif"" border=0 width="&iBarWidth&" height="&iBarHeight&" alt="""&aValues(I)&"""></a></td>"
Next
Response.Write"</tr>"&_
"<tr><td colspan="&(2*(UBound(aValues)+1))+1&"><img src=""images/spacer_black.gif"" border=0 width="&gr_BORDER+((UBound(aValues)+1)*(iBarWidth+gr_SPACER))&" height="&gr_BORDER&"></td></tr>"
If IsArray(aLabels) Then
Response.Write"<tr><td> </td>"
For I = 0 To UBound(aValues)
Response.Write"<td> </td><td align=center><font size=1>"&aLabels(I)&"</td>"
Next
Response.Write"</tr>"
End If
Response.Write"</table></td></tr><tr><td colspan=2> </td><td align=center><br><b>"&strXAxisLabel&"</td></tr></table>"
End Sub
%>
<html><body bgcolor=white>
<%
ShowChart Array(6, 10, 12, 18, 23, 26, 27, 28, 30, 34, 37, 45, 55), Array("P1", "P2", "P3", "P4", "P5", "P6", "P7", "P8", "P9", "P10", "P11", "P12", "P13"), "Chart Title", "X Label", "Y Label"
Response.Write"<br><br><br>"
Randomize
For I = 0 To 49
aTemp(I) = Int((50+1)*Rnd)
Next
ShowChart aTemp, "Note that this ain't an Array!", "Chart of 50 Random Numbers", "Index", "Value"
%>
</body></html>


Find an Images Dimensions

<%
dim iWidth, iHeight, iType
sub ImgDimension(img)
dim myImg, fs
Set fs= CreateObject("Scripting.FileSystemObject")
if not fs.fileExists(img) then exit sub
set myImg = loadpicture(img)
iWidth = round(myImg.width / 26.4583)
iHeight = round(myImg.height / 26.4583)
iType = myImg.Type
select case iType
case 0
iType = "None"
case 1
iType = "Bitmap"
case 2
iType = "Metafile"
case 3
iType = "Icon"
case 4
iType = "Win32-enhanced metafile"
end select
set myImg = nothing
end sub

' so if you whant to test it in asp just give the path to your image
ImgDimension(Server.MapPath("../.") & "\images\header.gif")

response.write("Dimensions: " & iWidth & " x " & iHeight & "<br>")
response.write("Image Type: " & iType & "<br>")


Validate Email Addresses using Regex in ASP

<%
'our function to check email addresses
'a fantastic list of regular expressions
Function CheckMail(strEmail)
'our variables
Dim objRegExp , blnValid
'create a new instance of the RegExp object , note we do not need Server.CreateObject("")
Set objRegExp = New RegExp
'this is our pattern we check .
objRegExp.Pattern = "^([a-zA-Z0-9_\-\.]+)@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}[0-9]{1,3})(\]?)$"
'store the result either true or false in blnValid
blnValid = objRegExp.Test(strEmail)
If blnValid Then
'display this if it is a vlid email address
Response.Write "This is a valid email address<br>"
Else
'display this if it is an invalid email address
Response.Write "That email address is invalid<br>"
End If
End Function
%>
<%CheckMail("validmail@email.com") 'correct email address %>
<%CheckMail("invalid1") 'incorrect , many errors%>
<%CheckMail("invalid+email.com") 'invalid + sign instead of @%>
<%CheckMail("invalid@email,com") 'invalid , sneaky uses a comma instead of a full stop%>


Testing for the XMLHTTP Request object

<% Option Explicit %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>XMLHTTP Request Object</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<%
'put the objects that we wish to test for into a declared array
Dim InstalledObjects(4)

InstalledObjects(0) ="Microsoft.XMLHTTP"
InstalledObjects(1) ="Msxml2.ServerXMLHTTP"
InstalledObjects(2) ="MSXML2.ServerXMLHTTP"
InstalledObjects(3) ="MSXML2.XMLHTTP.3.0"
InstalledObjects(4) ="MSXML2.XMLHTTP.4.0"

Function ObjCreated(sClass)
'create variable
Dim ObjInstance
On Error Resume Next
'initialize default values
ObjCreated = False
'create instance of the class - an object
Set ObjInstance = Server.CreateObject(sClass)
If Err.Number=0 Then ObjCreated = True
'close object
Set ObjInstance = Nothing
Err.Clear
End Function
%>
<table border="0">
<%
Dim i
For i=0 to UBound(InstalledObjects)
Response.Write "<tr><td>" & InstalledObjects(i) & "</td><td>"
If ObjCreated(InstalledObjects(i)) Then
Response.Write "<strong>Installed</strong>"
Else
Response.Write "<strong>not installed</strong>"
End If
Response.Write "</td></tr>"
Next
%>
</table>
</body>
</html>


A Feedback Form Script

<html>
<head>
<title>Feedback Form</title>
</head>
<body>

<%
'If the form has not been submitted execute the following code
If Request.Form="" Then %>
<form method="post" action="feedback.asp" name="form1">
<div align="center">Send us your Feedback.<br>
<br>
</div>
<div align="center">
<table width="75%" border="0">
<tr>
<td>name</td>
<td>
<input type="text" name="txtName">
</td>
</tr>
<tr>
<td>email</td>
<td>
<input type="text" name="txtEmail">
</td>
</tr>
<tr>
<td>comment</td>
<td>
<textarea name="txtFeedback" cols="40" rows="7"></textarea>
</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>&nbsp;</td>
</tr>
<tr>
<td>&nbsp;</td>
<td>
<input type="submit" name="Submit" value="Submit">
<input type="reset" name="Reset" value="Reset">
</td>
</tr>
</table>
</div>
</form>
<br>
<%
'If the form has been submitted execute the following code
Else

'receive the form values
Dim sName, sEmail, sFeedback
sName=Request.Form("txtName")
sEmail=Request.Form("txtEmail")
sFeedback=Request.Form("txtFeedback")

' create the HTML formatted email text
Dim sEmailText
sEmailText = sEmailText & "<html>"
sEmailText = sEmailText & "<head>"
sEmailText = sEmailText & "<title>HTML Email</title>"
sEmailText = sEmailText & "</head>"
sEmailText = sEmailText & "<body>"
sEmailText = sEmailText & "Feedback message from: " & sName & "<br>"
sEmailText = sEmailText & "Message:" & sFeedback & "<br>"
sEmailText = sEmailText & "Date & Time:" & Now() & "<br>"
sEmailText = sEmailText & "IP :" & Request.ServerVariables("REMOTE_ADDR")
sEmailText = sEmailText & "</body>"
sEmailText = sEmailText & "</html>"

'create the mail object
Set NewMailObj=Server.CreateObject("CDONTS.NewMail")
NewMailObj.From=sEmail 'This is the email of the feedback sender
NewMailObj.To = "michael@codefixer.com" 'change to your address
NewMailObj.Subject = "Feedback"
NewMailObj.Body = sEmailText
'you need to add these 2 lines for the mail to be sent in HTML format
'remove them and the email will be sent in Text format
NewMailObj.BodyFormat = 0
NewMailObj.MailFormat = 0
NewMailObj.Send
Set NewMailObj=Nothing

Response.write "<div align='center'>Thank you for sending your feedback.<br>"
Response.write "We will get back to you if necessary.</div>"
End If
%>
</body>
</html>


Password Protect Webpages

<%
'// by Ferruh Mavituna
'// ferruh@mavituna.com
'// http://ferruh.mavituna.com

Dim ThisPage
ThisPage = Request.ServerVariables("SCRIPT_NAME")

'// Set Session + password is Case Sensitive
If Request.Form("pass") <> "" Then
If Trim(Request.Form("pass")) = "yourpassword" Then Session("level") = "ok"
End If

'// Logout (xxx.asp?logout=ok)
If Request.Querystring("logout") <> "" Then Session("level") = ""

'// Ask for Login
If Session("level") <> "ok" Then
Response.Write "<form method=""post"" action=""" & ThisPage &amp; """><input type=""password"" name=""pass"" /><input type=""submit"" value=""Login""/></form>"
Response.End

Else '// Logged + Show logout button
Response.Write "<a href=""" & ThisPage &amp; "?logout=ok"">logout(x)</a>"
End If
%>


Sending Email in ASP

<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<%
If Request.Form("btnSubmit") <> "" Then
Dim UserName
Dim UserMessage
UserName = Request.Form("txtName")
UserMessage = Request.Form("txtMessage")
Dim Message
Message = "Mail from the Web site" & vbCrlf & vbCrLf
Message = Message & "User " & UserName & " left the following message: " & vbCrLf
Message = Message & UserMessage & vbCrLf & vbCrLf
Dim oMessage
Set oMessage = Server.CreateObject("CDONTS.NewMail.1")
'---- BodyFormat Property ----
Const CdoBodyFormatHTML = 0 ' The Body property is to include Hypertext Markup Language (HTML).
Const CdoBodyFormatText = 1 ' The Body property is to be exclusively in plain text (default value).
'---- MailFormat Property ----
Const CdoMailFormatMime = 0 ' The NewMail object is to be in MIME format.
Const CdoMailFormatText = 1 ' The NewMail object is to be in uninterrupted plain text (default value).
With oMessage
.To = "mbm@ardakankavosh.Com"
.Bcc = "bbm@Ardakankavosh.Com"
.From = "info@ardakankavosh.Com"
.Subject = "User " & UserName & " left a message"
.BodyFormat = CdoBodyFormatText ' CdoBodyFormatHTML
.MailFormat = CdoMailFormatMime
.Body = Message
.Send
End with
Set oMessage = Nothing
Response.Redirect("ThankYou.asp")
End If
%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Sending E-Mail woth ASP</title>
</head>
<body>
</body>
</html>


Convert integers into their Hex or Octal value

<%
Dim intNumber1 , intNumber2
'our two numbers
intNumber1 = 22
intNumber2 = 65
'convert them both
Response.Write "The octal of " & intNumber1 & " is " & Oct(intNumber1) & "<br>"
Response.Write "The octal of " & intNumber2 & " is " & Oct(intNumber2) & "<br>"
Response.Write "The hexadecimal of " & intNumber1 & " is " & Hex(intNumber1) & "<br>"
Response.Write "The hexadecimal of " & intNumber2 & " is " & Hex(intNumber2) & "<br>"
%>


Ban users based on IP Address

<%
'variables to store banned IP and the users IP
Dim strIP , strBannedIP
'this is the banned IP address
strBannedIP = "127.0.0.1"
'get the users IP address
strIP = Request.ServerVariables("LOCAL_ADDR")
'if users address is the same as the banned IP address
'display a message
If strBannedIP = strIP Then
Response.Write "You are not permitted to view this website"
'if usersa ddress is different welcome message is displayed
Else
Response.Write "welcome"
End If
%>


Using ADO to Update a Record in a Database

<% ID = 7 %>
<% NAME = "Joe Smoe" %>
<% MESSAGE = "This is another test" %>
<%
'declaring variables
'not neccesary but a good habit
Dim DataConn
Dim CmdUpdateRecord
Dim MYSQL
Set DataConn = Server.CreateObject("ADODB.Connection")
Set CmdUpdateRecord = Server.CreateObject("ADODB.Recordset")
'The line below shows how to use a system DSN instead of a DNS-LESS connection
'DataConn.Open "DSN=System_DSN_Name"
DataConn.Open "DBQ=" & Server.Mappath("../_database/database.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};"
MYSQL = "SELECT some_table.* FROM some_table WHERE (ID = " & ID & ")"
CmdUpdateRecord.Open MYSQL, DataConn, 1, 3
CmdUpdateRecord.Fields("NAME") = NAME
CmdUpdateRecord.Fields("MESSAGE") = MESSAGE
CmdUpdateRecord.Update
'closing objects and setting them to nothing
'not neccesary but a good habit
CmdUpdateRecord.Close
Set CmdUpdateRecord = Nothing
DataConn.Close
Set DataConn = Nothing
%>


Using ADO to add a New Record to Database

<% NAME = "Teddy Gordon" %>
<% MESSAGE = "This is a test" %>
<%
' declaring variables
' not neccesary but a good habit
Dim DataConn
Dim CmdAddRecord
Dim MYSQL
Set DataConn = Server.CreateObject("ADODB.Connection")
Set CmdAddRecord = Server.CreateObject("ADODB.Recordset")
' The line below shows how to use a system DSN instead of a DNS-LESS connection
' DataConn.Open "DSN=System_DSN_Name"
DataConn.Open "DBQ=" & Server.Mappath("../_database/database.mdb") & ";Driver={Microsoft Access Driver (*.mdb)};"
MYSQL = "SELECT some_table.* FROM some_table"
CmdAddRecord.Open MYSQL, DataConn, 1, 3
CmdAddRecord.AddNew
CmdAddRecord.Fields("NAME") = NAME
CmdAddRecord.Fields("MESSAGE") = MESSAGE
CmdAddRecord.Update
'closing objects and setting them to nothing
'not neccesary but a good habit
CmdAddRecord.Close
Set CmdAddRecord = Nothing
DataConn.Close
Set DataConn = Nothing
%>


A Cookie 'Remember me' style login script

<% Response.Buffer = True 'Buffers the content so Response.Redirect will work
Session("BlnAdministrator")=false 'Set our session object to false
'set the username and password
sUsername="codefixer"
sPassword="codefixer"
%>
<html>
<head>
<title>Cookie Login Script</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<%
'if form has not been filled in then display it otherwise check the details submitted
If Request.Form<>"" Then
If Request.form("checkbox") ="1" Then
Response.Cookies("UsernameCookie") = Request.Form("txtUsername")
Response.Cookies("PasswordCookie") = Request.Form("txtPassword")
Response.Cookies("RememberMeCookie") = "1"
Response.Cookies("UsernameCookie").expires = Now() + 60
Response.Cookies("PasswordCookie").expires = Now() + 60
Response.Cookies("RememberMeCookie").expires = Now() + 60
Else
Response.Cookies("RememberMeCookie") = ""
Response.Cookies("UsernameCookie") = ""
Response.Cookies("PasswordCookie") = ""
End If
'=== call checklogin subroutine
CheckLoginForm
Else
'=== call showlogin subroutine
ShowLoginForm
End If
'=== begin subroutine showlogin
Sub ShowLoginForm
%>
<div align="center"> <br>
<form name="form1" action="<%=Request.ServerVariables("SCRIPT_NAME")%>" method="post">
<table width="50%" border="1" align="center" cellpadding="4" cellspacing="0" bordercolor="#6185C1" bgcolor="EEF3FB">
<tr>
<td height="112" valign="top">
<table width='100%' border="0" cellpadding="3">
<tr>
<td colspan="2">&nbsp;</td>
</tr>
<tr>
<td width="45%">Username : </td>
<td width="54%"> <input value="<%= Request.Cookies("UsernameCookie") %>" name="txtUsername" type="text">
</td>
</tr>
<tr>
<td width="45%">Password : </td>
<td width="54%"> <input value="<%= Request.Cookies("PasswordCookie") %>" name="txtPassword" type="password">
</td>
</tr>
<tr>
<td width="45%">&nbsp;</td>
<td width="54%"> <input type="submit" value="Login" name="submit">
</td>
</tr>
<tr>
<td>Remember me</td>
<td><input value="1" type="checkbox" name="checkbox"
<% If Request.Cookies("RememberMeCookie") = "1" Then
Response.Write "CHECKED"
Else
Response.Write ""
End If %>>
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</div>

<%
'=== end showloginform subroutine
End Sub

'===begin subroutine checkloginform
Sub CheckLoginForm
txtUsername=Request.Form("txtUsername")
txtPassword=Request.Form("txtPassword")
'simple/basic protection against SQL injection use of the apostrophe
If InStr(1,txtUsername,"'",1) > 0 and InStr(1,txtPassword,"'",1) > 0 then
response.redirect "Login.asp"
Else
'check to see if the form details filled in match 'username' and 'password' above
If txtUsername = sUsername AND txtPassword = sPassword Then
'if the correct login details are filled in then set up a Session Object and redirect
'visitor to admin page
Session("BlnAdministrator") = True
Response.Redirect "admin.asp" 'set page you want to direct to on successful login
Else
'if the correct details aren't filled in then show the subroutine showloginform again
'and the statement below
ShowLoginForm
response.write "<div align='center'>Your login failed.</div>"
End If
End If
End Sub
'=== end subroutine checkloginform
%>
</body>
</html>


Get HTML Source Code from any URL

<%
dim objXMLHTTP
URL = Request.form("URL")
if ( URL = "" ) then
URL = "http://www.yahoo.com"
end if

Set objXMLHTTP = Server.CreateObject("Microsoft.XMLHTTP")
objXMLHTTP.Open "GET", URL, false
objXMLHTTP.Send

Response.Write "<hr>"
Response.Write "<h4>HTML Code for&nbsp"&URL&"</h4>"
Response.Write "<textarea rows=30 cols=120>"
Response.Write objXMLHTTP.responseText
Response.Write "</textarea>"
Set objXMLHTTP = Nothing
%>


Have Multiple Domains on a Single IP Address

<%
host = lcase(request.servervariables("HTTP_HOST"))
SELECT CASE host
CASE "www.chatventure.com"
response.redirect "http://127.0.0.1/folder0/main.htm"
CASE "www.cewebserver.com"
response.redirect "http://127.0.0.1/folder1/main.htm"
CASE ELSE
response.redirect "http://www.microsoft.com"
END SELECT
%>