超精华的asp代码大全

整理文档很辛苦,赏杯茶钱您下走!

免费阅读已结束,点击下载阅读编辑剩下 ...

阅读已结束,您可以下载文档离线阅读编辑

资源描述

显示页面加载时间重复域中的斑马线显示字符串前20个字符并在结尾处添加“……”如果动态图片为空,使用默认图片代替如果数据为空,使用默认提示信息代替●显示页面加载时间页面顶部添加下面的代码:%DimstrStartTimeDimstrEndTimestrStartTime=Timer'开始时间%页面(同一页)的末尾添加:%'加载完毕的时间strEndTime=TimerResponse.Write(页面加载时间:)Response.WriteFormatNumber(strEndTime-strStartTime,4)Response.Write(秒.)%●重复域中的斑马线%'此模块放置在重复域之外DimRecordCounterRecordcounter=0%trclass=%'将重复域中第一个tr标签的CLASS属性代码用本模块替换'本模块基于CSS来改变单元格背景色,你也可以直接设置背景色来实现斑马线RecordCounter=Recordcounter+1IfRecordCounterMod2=1ThenResponse.WritealtRow1ElseResponse.writealtRow2EndIf%●显示字符串前20个字符并在结尾处添加“……”%DimCutShortCutShort=rsYourRecordset.Fields.Item(YourField).ValueResponse.WriteLEFT(CutShort,20)&........%●如果动态图片为空,用默认图片代替%DimPicShowPicShow=rsShowHide.Fields.Item(shMainPix).ValueIFPicShowTHEN%imgsrc=%=rsShowHide.Fields.Item(shMainPix).Value%%ELSE%imgsrc=StaticPic.gif%EndIf%●如果数据为空,用默认提示信息代替。%DimstrShowHidestrShowHide=rsYourRecordset.Fields.Item(YourDataField).ValueIFstShowHideTHEN%数据为空%ENDIF%纯编码实现Access数据库的建立或压缩%'#######以下是一个类文件,下面的注解是调用类的方法################################################'#注意:如果系统不支持建立Scripting.FileSystemObject对象,那么数据库压缩功能将无法使用'#Access数据库类'#CreateDbFile建立一个Access数据库文件'#CompactDatabase压缩一个Access数据库文件'#建立对象方法:'#Seta=NewDatabaseTools'#by(萧寒雪)s.f.'#########################################################################################ClassDatabaseToolsPublicfunctionCreateDBfile(byValdbFileName,byValDbVer,byValSavePath)'建立数据库文件'IfDbVeris0ThenCreateAccess97dbFile'IfDbVeris1ThenCreateAccess2000dbFileOnerrorresumeNextIfRight(SavePath,1)\OrRight(SavePath,1)/ThenSavePath=Trim(SavePath)&\IfLeft(dbFileName,1)=\OrLeft(dbFileName,1)=/ThendbFileName=Trim(Mid(dbFileName,2,Len(dbFileName)))IfDbExists(SavePath&dbFileName)ThenResponse.Write(对不起,该数据库已经存在!)CreateDBfile=FalseElseDimCaSetCa=Server.CreateObject(ADOX.Catalog)IfErr.number0ThenResponse.Write(无法建立,请检查错误信息&Err.number&&Err.Description)Err.ClearExitfunctionEndIfIfDbVer=0ThencallCa.Create(Provider=Microsoft.Jet.OLEDB.3.51;DataSource=&SavePath&dbFileName)ElsecallCa.Create(Provider=Microsoft.Jet.OLEDB.4.0;DataSource=&SavePath&dbFileName)EndIfSetCa=NothingCreateDBfile=TrueEndIfEndfunctionPublicfunctionCompactDatabase(byValdbFileName,byValDbVer,byValSavePath)'压缩数据库文件'0为access97'1为access2000OnErrorresumenextIfRight(SavePath,1)\OrRight(SavePath,1)/ThenSavePath=Trim(SavePath)&\IfLeft(dbFileName,1)=\OrLeft(dbFileName,1)=/ThendbFileName=Trim(Mid(dbFileName,2,Len(dbFileName)))IfDbExists(SavePath&dbFileName)ThenResponse.Write(对不起,该数据库已经存在!)CompactDatabase=FalseElseDimCdSetCd=Server.CreateObject(JRO.JetEngine)IfErr.number0ThenResponse.Write(无法压缩,请检查错误信息&Err.number&&Err.Description)Err.ClearExitfunctionEndIfIfDbVer=0ThencallCd.CompactDatabase(Provider=Microsoft.Jet.OLEDB.3.51;DataSource=&SavePath&dbFileName,Provider=Microsoft.Jet.OLEDB.3.51;DataSource=&SavePath&dbFileName&.bak.mdb;JetOLEDB;EncryptDatabase=True)ElsecallCd.CompactDatabase(Provider=Microsoft.Jet.OLEDB.4.0;DataSource=&SavePath&dbFileName,Provider=Microsoft.Jet.OLEDB.4.0;DataSource=&SavePath&dbFileName&.bak.mdb;JetOLEDB;EncryptDatabase=True)EndIf'删除旧的数据库文件callDeleteFile(SavePath&dbFileName)'将压缩后的数据库文件还原callRenameFile(SavePath&dbFileName&.bak.mdb,SavePath&dbFileName)SetCd=FalseCompactDatabase=TrueEndIfendfunctionPublicfunctionDbExists(byValdbPath)'查找数据库文件是否存在OnErrorresumeNextDimcSetc=Server.CreateObject(ADODB.Connection)c.OpenProvider=Microsoft.Jet.OLEDB.4.0;DataSource=&dbPathIfErr.number0ThenErr.ClearDbExists=falseelseDbExists=TrueEndIfsetc=nothingEndfunctionPublicfunctionAppPath()'取当前真实路径AppPath=Server.MapPath(./)EndfunctionPublicfunctionAppName()'取当前程序名称AppName=Mid(Request.ServerVariables(SCRIPT_NAME),(InStrRev(Request.ServerVariables(SCRIPT_NAME),/,-1,1))+1,Len(Request.ServerVariables(SCRIPT_NAME)))EndFunctionPublicfunctionDeleteFile(filespec)'删除一个文件DimfsoSetfso=CreateObject(Scripting.FileSystemObject)IfErr.number0ThenResponse.Write(删除文件发生错误!请查看错误信息&Err.number&&Err.Description)Err.ClearDeleteFile=FalseEndIfcallfso.DeleteFile(filespec)Setfso=NothingDeleteFile=TrueEndfunctionPublicfunctionRenameFile(filespec1,filespec2)'修改一个文件DimfsoSetfso=CreateObject(Scripting.FileSystemObject)IfErr.number0ThenResponse.Write(修改文件名时发生错误!请查看错误信息&Err.number&&Err.Description)Err.ClearRenameFile=FalseEndIfcallfso.CopyFile(filespec1,filespec2,True)callfso.DeleteFile(filespec1)Setfso=NothingRenameFile=TrueEndfunctionEndClass%现在已可以压缩有密码的数据库,代码如下,但是压缩之后的数据库密码就没有了!如何解决?%ConstJET_3X=4FunctionCompactDB(dbPath,boolIs97)Dimfso,Engine,strDBPathstrDBPath=left(dbPath,instrrev(DBPath,\))Setfso=CreateObject(Scripting.FileSystemObject)Iffso.FileExists(dbPath)ThenSetEngine=CreateObject(JRO.JetEngine)IfboolIs97=TrueThenEngine.CompactDatabaseProvider=Microsoft.Jet.OLEDB.4.0;DataSource=&dbpath,_Provider=Microsoft.Jet.OLEDB.4.0;JetOLEDB:DatabasePassword='XXXXXXXX';DataSource=&strDBPath&temp.mdb;_&JetOLEDB:EngineType=&JET_3XElseEngine.CompactDatabaseProvider=Microsoft.Jet.OLEDB.4.0;JetOLEDB:DatabasePassword='XXXXXXXX';DataSource=&dbpath,_Provider=Microsoft.Jet.OLE

1 / 34
下载文档,编辑使用

©2015-2020 m.777doc.com 三七文档.

备案号:鲁ICP备2024069028号-1 客服联系 QQ:2149211541

×
保存成功