% #######以下是一个类文件,下面的注解是调用类的方法################################################ # 注意:如果系统不支持 建立 scripting.filesystemobject对象,那么 数据库 压缩 功能将无法使用 # access 数据库 类 # createdbfile 建立 一个acce
’#######以下是一个类文件,下面的注解是调用类的方法################################################’# 注意:如果系统不支持建立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.number0 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