|
![]() |
名片设计 CorelDRAW Illustrator AuotoCAD Painter 其他软件 Photoshop Fireworks Flash |
|
<% on error resume next class createdb \\\' \\\' \\\'建立一个数据库 \\\'用法: \\\'dim cdb \\\'set cdb=new createdb \\\'cdb.setdbname=数据库名 \\\'if cdb.ifok then response.end 数据库已经存在 \\\'cdb.run \\\'检查是否运行成功 \\\'if cdb.ifok then \\\'response.write cdb.errs \\\'end if private dbname \\\'数据库名字 private ifsure \\\'用来保存是否成功的标志,假如成功值为false,失败为true,初值为true private errstr \\\'保存说明错误的文字 \\\'获取ifsure值 property get ifok() ifok=ifsure end property \\\'获取errstr值 property get errs() errs=errstr end property \\\' private sub class_initialize() \\\'设置ifsure,errstr的初值 ifsure=true errstr="在线建库" end sub \\\'设置数据库名 property let setdbname(byval dbn) dbname=dbn \\\'检查数据库是否已经存在 ifexistdb dbn end property public sub run() \\\' class_initialize \\\'检查数据库名是否为空 if isnull(dbname) or isempty(dbname) or cstr(dbname)="" then errstr="建立数据库失败,数据库名不能为空" ifsure=true exit sub end if \\\'这句不能放在ifexistdb里,也不能随后执行,因为找不到数据库后自动退出这个类, \\\'可能是太严峻的错误吧,所以只能在另一个地方清理错误码了 err.clear dim objcreate \\\'保存ADOX.CATALOG对象 set objcreate=Server.CreateObject("adox.catalog") if err.number<>0 then errstr="建立adox.catalog对象失败,请检查你的用户权限。"+err.description set objcreate=nothing ifsure=true exit sub end if \\\'建立数据库 objcreate.create("data source="+server.mappath(dbname)+";provider=microsoft.jet.oledb.4.0") if err.number<>0 then errstr="建立数据库失败。<br>"+err.description ifsure=true set objcreate=nothing exit sub end if \\\'假如没有出错,设置成功标志 ifsure=false end sub private sub ifexistdb(byval dbn) \\\'还原类状态 ifsure=false \\\'假如数据库存在,就设为true,因为假如不存在的话就不能继承执行这个类 \\\'检查数据库是否已经存在 dim conn set conn=server.createobject("adodb.connection") conn.connectionstring="provider=microsoft.jet.oledb.4.0;data source="+server.mappath(dbn) conn.open if err.number=0 then errstr="数据库已经存在" ifsure=true conn.close set conn=nothing end if end sub end class %> 返回类别: 教程 上一教程: ASP定时组件 下一教程: ASP生成柱型体、折线图、饼图源代码 您可以阅读与"在线建库"相关的教程: · 利用ASP在线维护数据库 · 用ASP开发试题库与在线考试系统(4) · 网页在线人数统计的做法 · ASP进阶之文章在线治理更新(3) · 用ASP实现聊天室中的在线答题游戏 |
![]() ![]() |
快精灵印艺坊 版权所有 |
首页![]() ![]() ![]() ![]() ![]() ![]() ![]() |