通过本文主要向大家介绍了asp代码大全,asp代码,asp源代码,asp登录界面代码,asp跳转页面代码等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
显示页面加载时间
重复域中的斑马线
显示字符串前20个字符并在结尾处添加“……”
如果动态图片为空,使用默认图片代替
如果数据为空,使用默认提示信息代替
●显示页面加载时间
页面顶部添加下面的代码:
<%
Dim strStartTime
Dim strEndTime
strStartTime = Timer '开始时间
%>
页面(同一页)的末尾添加:
<%
' 加载完毕的时间
strEndTime = Timer
Response.Write ("页面加载时间: ")
Response.Write FormatNumber(strEndTime - strStartTime, 4)
Response.Write (" 秒.")
%>
●重复域中的斑马线
<%
'此模块放置在重复域之外
Dim RecordCounter
Recordcounter = 0
%>
<tr class =
<%
'将重复域中第一个 <tr>标签的CLASS属性代码用本模块替换
'本模块基于CSS来改变单元格背景色,你也可以直接设置背景色来实现斑马线
RecordCounter = Recordcounter + 1
If RecordCounter Mod 2 = 1 Then
Response.Write "altRow1"
Else
Response.write "altRow2"
End If
%>
●显示字符串前20个字符并在结尾处添加“……”
<%
Dim CutShort
CutShort = rsYourRecordset.Fields.Item("YourField").Value
Response.Write LEFT (CutShort, 20) & "........"
%>
●如果动态图片为空,用默认图片代替
<%
Dim PicShow
PicShow = rsShowHide.Fields.Item("shMainPix").Value
IF PicShow <>"" THEN %>
<img src="<%=rsShowHide.Fields.Item("shMainPix").Value%>">
<% ELSE %>
<img src="StaticPic.gif">
<% End If %>
●如果数据为空,用默认提示信息代替。
<%
Dim strShowHide
strShowHide = rsYourRecordset.Fields.Item("YourDataField").Value
IF stShowHide <>"" THEN%>
数据为空
<%END IF%>
纯编码实现Access数据库的建立或压缩
<%
'#######以下是一个类文件,下面的注解是调用类的方法################################################
'# 注意:如果系统不支持建立Scripting.FileSystemObject对象,那么数据库压缩功能将无法使用
'# Access 数据库类
'# CreateDbFile 建立一个Access 数据库文件
'# CompactDatabase 压缩一个Access 数据库文件
'# 建立对象方法:
'# Set a = New DatabaseTools
'# by (萧寒雪) s.f.
'#########################################################################################
Class DatabaseTools
Public function CreateDBfile(byVal dbFileName,byVal DbVer,byVal SavePath)
'建立数据库文件
'If DbVer is 0 Then Create Access97 dbFile
'If DbVer is 1 Then Create Access2000 dbFile
On error resume Next
If Right(SavePath,1)<>"\" Or Right(SavePath,1)<>"/" Then SavePath = Trim(SavePath) & "\"
If Left(dbFileName,1)="\" Or Left(dbFileName,1)="/" Then dbFileName = Trim(Mid(dbFileName,2,Len(dbFileName)))
If DbExists(SavePath & dbFileName) Then
Response.Write ("对不起,该数据库已经存在!")
CreateDBfile = False
Else
Dim Ca
Set Ca = Server.CreateObject("ADOX.Catalog")
If Err.number<>0 Then
Response.Write ("无法建立,请检查错误信息
" & Err.number & "
" & Err.Description)
Err.Clear
Exit function
End If
If DbVer=0 Then
call Ca.Create("Provider=Microsoft.Jet.OLEDB.3.51;Data Source=" & SavePath & dbFileName)
Else
call Ca.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & SavePath & dbFileName)
End If
Set Ca = Nothing
CreateDBfile = True
End If
End function
Public function CompactDatabase(byVal dbFileName,byVal DbVer,byVal SavePath)
'压缩数据库文件
'0 为access 97
'1 为access 2000
On Error resume next
If Right(SavePath,1)<>"\" Or Right(SavePath,1)<>"/" Then SavePath = Trim(SavePath) & "\"
If Left(dbFileName,1)="\" Or Left(dbFileName,1)="/" Then dbFileName = Trim(Mid(dbFileName,2,Len(dbFileName)))
If DbExists(SavePath & dbFileName) Then
Response.Write ("对不起,该数据库已经存在!")
CompactDatabase = False
Else
Dim Cd
Set Cd =Server.CreateObject("JRO.JetEngine")
If Err.number<>0 Then
Response.Write ("无法压缩,请检查错误信息
" & Err.number & "
" & Err.Description)
Err.Clear
Exit function
End If
If DbVer=0 Then
call Cd.CompactDatabase("Provider=Microsoft.Jet.OLEDB.3.51;Data Source=" & SavePath & dbFileName,"Provider=Microsoft.Jet.OLEDB.3.51;Data
Source=" & SavePath & dbFileName & ".bak.mdb;Jet OLEDB;Encrypt Database=True")
Else
call Cd.CompactDatabase("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
SavePath & dbFileName,"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
SavePath & dbFileName & ".bak.mdb;Jet OLEDB;Encrypt Database=True")
End If
'删除旧的数据库文件
call DeleteFile(SavePath & dbFileName)
'将压缩后的数据库文件还原
call RenameFile(SavePath & dbFileName & ".bak.mdb",SavePath & dbFileName)
Set Cd = False
CompactDatabase = True
End If
end function
Public function DbExists(byVal dbPath)
'查找数据库文件是否存在
On Error resume Next
Dim c
Set c = Server.CreateObject("ADODB.Connection")
c.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbPath
If Err.number<>0 Then
Err.Clear
DbExists = false
else
DbExists = True
End If
set c = nothing
End function
Public function AppPath()
'取当前真实路径
AppPath = Server.MapPath("./")
End function
Public function AppName()
'取当前程序名称
AppName = Mid(Request.ServerVariables("SCRIPT_NAME"),(InStrRev(Request.ServerVariables("SCRIPT_NAME") ,"/",-1,1))+1,Len(Request.ServerVariables("SCRIPT_NAME")))
End Function
Public function DeleteFile(filespec)
'删除一个文件
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
If Err.number<&
重复域中的斑马线
显示字符串前20个字符并在结尾处添加“……”
如果动态图片为空,使用默认图片代替
如果数据为空,使用默认提示信息代替
●显示页面加载时间
页面顶部添加下面的代码:
<%
Dim strStartTime
Dim strEndTime
strStartTime = Timer '开始时间
%>
页面(同一页)的末尾添加:
<%
' 加载完毕的时间
strEndTime = Timer
Response.Write ("页面加载时间: ")
Response.Write FormatNumber(strEndTime - strStartTime, 4)
Response.Write (" 秒.")
%>
●重复域中的斑马线
<%
'此模块放置在重复域之外
Dim RecordCounter
Recordcounter = 0
%>
<tr class =
<%
'将重复域中第一个 <tr>标签的CLASS属性代码用本模块替换
'本模块基于CSS来改变单元格背景色,你也可以直接设置背景色来实现斑马线
RecordCounter = Recordcounter + 1
If RecordCounter Mod 2 = 1 Then
Response.Write "altRow1"
Else
Response.write "altRow2"
End If
%>
●显示字符串前20个字符并在结尾处添加“……”
<%
Dim CutShort
CutShort = rsYourRecordset.Fields.Item("YourField").Value
Response.Write LEFT (CutShort, 20) & "........"
%>
●如果动态图片为空,用默认图片代替
<%
Dim PicShow
PicShow = rsShowHide.Fields.Item("shMainPix").Value
IF PicShow <>"" THEN %>
<img src="<%=rsShowHide.Fields.Item("shMainPix").Value%>">
<% ELSE %>
<img src="StaticPic.gif">
<% End If %>
●如果数据为空,用默认提示信息代替。
<%
Dim strShowHide
strShowHide = rsYourRecordset.Fields.Item("YourDataField").Value
IF stShowHide <>"" THEN%>
数据为空
<%END IF%>
纯编码实现Access数据库的建立或压缩
<%
'#######以下是一个类文件,下面的注解是调用类的方法################################################
'# 注意:如果系统不支持建立Scripting.FileSystemObject对象,那么数据库压缩功能将无法使用
'# Access 数据库类
'# CreateDbFile 建立一个Access 数据库文件
'# CompactDatabase 压缩一个Access 数据库文件
'# 建立对象方法:
'# Set a = New DatabaseTools
'# by (萧寒雪) s.f.
'#########################################################################################
Class DatabaseTools
Public function CreateDBfile(byVal dbFileName,byVal DbVer,byVal SavePath)
'建立数据库文件
'If DbVer is 0 Then Create Access97 dbFile
'If DbVer is 1 Then Create Access2000 dbFile
On error resume Next
If Right(SavePath,1)<>"\" Or Right(SavePath,1)<>"/" Then SavePath = Trim(SavePath) & "\"
If Left(dbFileName,1)="\" Or Left(dbFileName,1)="/" Then dbFileName = Trim(Mid(dbFileName,2,Len(dbFileName)))
If DbExists(SavePath & dbFileName) Then
Response.Write ("对不起,该数据库已经存在!")
CreateDBfile = False
Else
Dim Ca
Set Ca = Server.CreateObject("ADOX.Catalog")
If Err.number<>0 Then
Response.Write ("无法建立,请检查错误信息
" & Err.number & "
" & Err.Description)
Err.Clear
Exit function
End If
If DbVer=0 Then
call Ca.Create("Provider=Microsoft.Jet.OLEDB.3.51;Data Source=" & SavePath & dbFileName)
Else
call Ca.Create("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & SavePath & dbFileName)
End If
Set Ca = Nothing
CreateDBfile = True
End If
End function
Public function CompactDatabase(byVal dbFileName,byVal DbVer,byVal SavePath)
'压缩数据库文件
'0 为access 97
'1 为access 2000
On Error resume next
If Right(SavePath,1)<>"\" Or Right(SavePath,1)<>"/" Then SavePath = Trim(SavePath) & "\"
If Left(dbFileName,1)="\" Or Left(dbFileName,1)="/" Then dbFileName = Trim(Mid(dbFileName,2,Len(dbFileName)))
If DbExists(SavePath & dbFileName) Then
Response.Write ("对不起,该数据库已经存在!")
CompactDatabase = False
Else
Dim Cd
Set Cd =Server.CreateObject("JRO.JetEngine")
If Err.number<>0 Then
Response.Write ("无法压缩,请检查错误信息
" & Err.number & "
" & Err.Description)
Err.Clear
Exit function
End If
If DbVer=0 Then
call Cd.CompactDatabase("Provider=Microsoft.Jet.OLEDB.3.51;Data Source=" & SavePath & dbFileName,"Provider=Microsoft.Jet.OLEDB.3.51;Data
Source=" & SavePath & dbFileName & ".bak.mdb;Jet OLEDB;Encrypt Database=True")
Else
call Cd.CompactDatabase("Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
SavePath & dbFileName,"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" &
SavePath & dbFileName & ".bak.mdb;Jet OLEDB;Encrypt Database=True")
End If
'删除旧的数据库文件
call DeleteFile(SavePath & dbFileName)
'将压缩后的数据库文件还原
call RenameFile(SavePath & dbFileName & ".bak.mdb",SavePath & dbFileName)
Set Cd = False
CompactDatabase = True
End If
end function
Public function DbExists(byVal dbPath)
'查找数据库文件是否存在
On Error resume Next
Dim c
Set c = Server.CreateObject("ADODB.Connection")
c.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & dbPath
If Err.number<>0 Then
Err.Clear
DbExists = false
else
DbExists = True
End If
set c = nothing
End function
Public function AppPath()
'取当前真实路径
AppPath = Server.MapPath("./")
End function
Public function AppName()
'取当前程序名称
AppName = Mid(Request.ServerVariables("SCRIPT_NAME"),(InStrRev(Request.ServerVariables("SCRIPT_NAME") ,"/",-1,1))+1,Len(Request.ServerVariables("SCRIPT_NAME")))
End Function
Public function DeleteFile(filespec)
'删除一个文件
Dim fso
Set fso = CreateObject("Scripting.FileSystemObject")
If Err.number<&