Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

j

« Newer Snippets
Older Snippets »
Showing 1-4 of 4 total  RSS 

Vbscript Array sort in alphabetical order

// sort vbscript array

<%
dim arrSortOut(8)
arrSortOut(0)="xCount"
arrSortOut(1)="zExec"
arrSortOut(2)="yFinance"
arrSortOut(3)="HR"
arrSortOut(4)="IT "
arrSortOut(5)="!aaaLegal"
arrSortOut(6)="Liberman"
arrSortOut(7)="Martha"
arrSortOut(8)="Regis"

for x=0 to 8
response.write arrSortOut(x)&"<br>"
next

response.write "<br>"

for i = UBound(arrSortOut) - 1 To 0 Step -1
    for j= 0 to i
        if arrSortOut(j)>arrSortOut(j+1) then
            temp=arrSortOut(j+1)
            arrSortOut(j+1)=arrSortOut(j)
            arrSortOut(j)=temp
        end if
    next
next 


for x=0 to 8
response.write arrSortOut(x)&"<br>"
next

%>

Write all ASP page variables

// description of your code here

<%
  Response.Write "Server Variables" & "<br><br>"
For Each strName in Request.ServerVariables
  Response.Write strName & " - " & Request.ServerVariables(strName) & "<BR>"
Next

  Response.Write "Session Variables" & "<br><br>"
For Each strName in Session.Contents
  Response.Write strName & " - " & Session.Contents(strName) & "<BR>"
Next

  Response.Write "Form Variables" & "<br><br>"
For Each strName in request.form
  Response.Write strName & " - " & request.form(strName) & "<BR>"
Next

  Response.Write "String Variables" & "<br><br>"
For Each strName in request.querystring
  Response.Write strName & " - " & request.querystring(strName) & "<BR>"
Next
%>

Simple FSO directory file listing

// simple browsing tool

<%

dim aryURL, URLvar
aryURL = Split(Request.ServerVariables("SCRIPT_NAME"), "/", -1, 1)
URLvar = aryURL(ubound(aryURL))

if request.querystring("sPP")<>"" then 
	
	sPP=request.querystring("sPP") & "\"
	ParentVar="<a href=""#"" onClick=""history.go(-1)"">Parent Directory</a><br><br>" & vbCrLF
else
	sPP = "\\serverlocation\"
end if

	
	Set fso = CreateObject("Scripting.FileSystemObject")
	Set f = fso.GetFolder(sPP)  
	Set fc = f.Files 
	Set ff = f.SubFolders 
	For Each f1 in ff	
	  HeaderVar=HeaderVar& "<a href=""" & URLvar & "?sPP=" & sPP & f1.name & """>" & f1.name & "</a> &nbsp;|&nbsp;" & vbCrLF
	Next  
	For Each f1 in fc
	  SubHeaderVar=SubHeaderVar& "<a href=""" & sPP & f1.name & """>" & f1.name & "</a> <br>" & vbCrLF
	Next  
	Set ff = nothing
	Set fso = nothing
	Set f = nothing
	Set fc = nothing


response.write ParentVar
if HeaderVar<>"" then response.write "<b>Folders" & vbCrLF & "<br><br>&nbsp;|&nbsp;" & vbCrLF & HeaderVar & "</b><br><br>" & vbCrLF
if SubHeaderVar<>"" then response.write "<b>Files</b>" & vbCrLF & "<br><br>" & vbCrLF & SubHeaderVar & vbCrLF

%>




SQL server ASP database test

// basic sql server database asp code test

<%
str_ConnectionString = "Provider=SQLOLEDB;Data Source=servername;Initial Catalog=database;User Id=user;Password=pwd;"
Set oConn = Server.CreateObject("ADODB.Connection")
oConn.Open str_ConnectionString

set rs = Server.CreateObject("ADODB.recordset")
strSQL="select * from tablename"

rs.Open strSQL, oConn

do until rs.EOF
	for each x in rs.Fields
		response.write x.value & "|"
	next
	rs.MoveNext
	response.write "<br>"
loop	

rs.Close

oConn.Close
set oConn = Nothing
%>
« Newer Snippets
Older Snippets »
Showing 1-4 of 4 total  RSS