Private Sub Form_Load()
   Dim conn As New ADODB.Connection
   Dim rsTmp As New ADODB.Recordset
   
   conn.Open "provider=Microsoft.Jet.OLEDB.4.0; Data Source=E:\db1.mdb;Persist Security Info=False"
   With rsTmp
        If .State = adStateOpen Then .Close
        .Open "select  ID,姓名 from LT1", conn, adOpenStatic, adLockOptimistic
        If .RecordCount > 0 Then
           MsgBox "Succeed!"
        Else
           MsgBox "Failed!"
        End If
   End With
       
End Sub
Public Function Fun打开数据(StrFileName As String, Optional Bln只读 As Boolean = True) As ADODB.Connection
    Dim strConn As String, strDBPath As String, strPassword As String
    Dim Cnthis As New ADODB.Connection
    
    On Error GoTo ErrHandle
    strPassword = "zlnkjyx"
    SysPath = GetSetting(UCase("zlyxxzj"), "SYSTEM", "Data", App.Path & "\")
    strDBPath = StrFileName
    If Len(StrFileName) = 0 Then
        strDBPath = GetSetting(UCase("zlyxxzj"), "SYSTEM", "Data", App.Path & "\")
        strDBPath = strDBPath & "SystemMDB.MDB"
    End If
    strConn = "Provider=Microsoft.Jet.OLEDB.3.51;Persist Security Info=False;Data Source=" & _
        strDBPath & ";Jet OLEDB:Database Password=" & strPassword & ";"
    Set Cnthis = New ADODB.Connection
    Cnthis.ConnectionString = strConn
    Cnthis.Open
    Set Fun打开数据 = Cnthis
    Exit Function
    
ErrHandle:
    Set Fun打开数据 = Nothing
    MsgBox "数据库打开失败", vbInformation, App_Name
End Function