資源描述:
《ASP編程技巧大全》由會(huì)員上傳分享,免費(fèi)在線閱讀,更多相關(guān)內(nèi)容在工程資料-天天文庫(kù)。
1、ASP編程技巧大全<%''#######以下是一個(gè)類文件,下面的注解是調(diào)用類的方法################################################''#注意:如果系統(tǒng)不支持建立Scripting.FileSystemObject對(duì)象,那么數(shù)據(jù)庫(kù)壓縮功能將無(wú)法使用''#Access數(shù)據(jù)庫(kù)類''#CreateDbFile建立一個(gè)Access數(shù)據(jù)庫(kù)文件''#CompactDatabase壓縮一個(gè)Access數(shù)據(jù)庫(kù)文件''#建立對(duì)象方法:''#Seta=NewDatabaseTools''#by(蕭寒雪
2、)s.f.''#########################################################################################ClassDatabaseToolsPublicfunctionCreateDBfile(byValdbFileName,byValDbVer,byValSavePath)''建立數(shù)據(jù)庫(kù)文件''IfDbVeris0ThenCreateAccess97dbFile''IfDbVeris1ThenCreateAccess2000dbFileO
3、nerrorresumeNextIfRight(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("對(duì)不起,該數(shù)據(jù)庫(kù)已經(jīng)存在!")Cre
4、ateDBfile=FalseElseDimCaSetCa=Server.CreateObject("ADOX.Catalog")IfErr.number<>0ThenResponse.Write("無(wú)法建立,請(qǐng)檢查錯(cuò)誤信息"&Err.number&""&Err.Description)Err.ClearExitfunctionEndIfIfDbVer=0ThencallCa.Create("Provider=Microsoft.Jet.OLEDB.3.51;DataSource="&SavePath&dbFileName)E
5、lsecallCa.Create("Provider=Microsoft.Jet.OLEDB.4.0;DataSource="&SavePath&dbFileName)EndIfSetCa=NothingCreateDBfile=TrueEndIfEndfunctionPublicfunctionCompactDatabase(byValdbFileName,byValDbVer,byValSavePath)''壓縮數(shù)據(jù)庫(kù)文件''0為access97''1為access2000OnErrorresumenextIfRight(
6、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("對(duì)不起,該數(shù)據(jù)庫(kù)已經(jīng)存在!")CompactDatabase=FalseElseDi
7、mCdSetCd=Server.CreateObject("JRO.JetEngine")IfErr.number<>0ThenResponse.Write("無(wú)法壓縮,請(qǐng)檢查錯(cuò)誤信息"&Err.number&""&Err.Description)Err.ClearExitfunctionEndIfIfDbVer=0ThencallCd.CompactDatabase("Provider=Microsoft.Jet.OLEDB.3.51;DataSource="&SavePath&dbFileName,"Provider=Mi
8、crosoft.Jet.OLEDB.3.51;DataSource="&SavePath&dbFileName&".bak.mdb;JetOLEDB;EncryptDatabase=True")ElsecallCd.CompactDatabase("Provider=Micr