'先引用Mcrsoft DAO 3.6(或2.5或3.51) Object Library和Mcrsoft Access 9.0 Object Library,在Form上加个Command1,粘贴以下代码: Private Sub Command1_Click() If Dir("D:\NewDB.mdb") <> "" Then Kill "D:\NewDB.mdb" End Sub
Dim wrkDefault As Workspace
Dim dbsNew As Database
Dim tdfNew As TableDef
Dim NewDB As Database
'{取当前目录的话去掉路径: If Dir("NewDB.mdb") <> "" Then Kill "NewDB.mdb")}
Set wrkDefault = DBEngine.Workspaces(0)
Set dbsNew = wrkDefault.CreateDatabase("d:\NewDB.mdb", dbLangGeneral, dbEncrypt)
'{取当前目录的话去掉路径: Set dbsNew = wrkDefault.CreateDatabase("NewDB.mdb", dbLangGeneral, dbEncrypt)}
dbsNew.NewPassword "", "123" '设置数据库密码为123
Set wrkDefault = Nothing
Set dbsNew = Nothing
文章来源于领测软件测试网 https://www.ltesting.net/
版权所有(C) 2003-2010 TestAge(领测软件测试网)|领测国际科技(北京)有限公司|软件测试工程师培训网 All Rights Reserved
北京市海淀区中关村南大街9号北京理工科技大厦1402室 京ICP备10010545号-5
技术支持和业务联系:info@testage.com.cn 电话:010-51297073