|
本帖最后由 鱼儿游游 于 2010-12-25 01:56 编辑
'创建一个数据库
'
'首先在项目中添加引用->Microsoft ADO Ext. 2.x for DLL and Security
'
'成功创建指定的数据库返回:True, 否则:返回:False
'
Public Function CreateDatabase(strDBPath As String, Optional ByVal strDBPwd As String = "", Optional ByVal IsDisPlayErrMsg As Boolean = False) As Boolean
On Error Resume Next
Dim cat As New ADOX.Catalog
cat.Create "provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & strDBPath & ";Jet OLEDB:database Password=" & strDBPwd
Set cat = Nothing
If Err <> 0 And IsDisPlayErrMsg Then MsgBox Err.Source & "-->" & Err.Description, , "创建数据库失败"
CreateDatabase = Err.Number = 0
End Function
Sub test()
CreateDatabase "c:\test.mdb", "newpassword", true
End Sub
|
评分
-
查看全部评分
|