adodc 访问带密码的access

来源:百度知道 编辑:UC知道 时间:2024/05/21 21:07:11
有无高人能给个adodc 访问带密码的access的模块代码 或者是界面代码

数据库名字a.db 密码123456

Private Sub Form_Load()
1楼朋友的不行啊 还是那个提示:无法启动应用程序。工作组信息丢失,或者已经被其他用户已独占方式打开。

2楼朋友能具体点吗?

Public Function MakeConnection() As String
'连接了数据库的函数过程,定义为字符类型。
Set cn = New ADODB.Connection
On Error GoTo connecterr
With cn
.CursorLocation = adUseClient
.ConnectionString = "DRIVER={Microsoft Access Driver (*.mdb)};" & _
"DBQ=d:\a.mdb;" & _
"DefaultDir=" & CheckPath(App.path) & ";" & _
"UID=;PWD=123456;" '数据库密码,防止被人用其它软件打开数据库
.Open
End With
MakeConnection = "OK" '成功连接,定义为OK
Exit Function
connecterr: '连接出错的标识
Dim I As Integer
Dim sError As String '连接出错标识的变量
If cn.Errors.Count > 0 Then
For I = 0 To cn.Errors.Count - 1
sError = sError & cn.Errors(I).Number & ":" &