Dim Conn As ADODB.Connection '定义ADODB连接的对象 Dim Record As ADODB.Recordset '定义ADODB对象的记录集 Dim ConnStr As String '定义连接字符串 Set Conn = New ADODB.Connection '给对象分配空间 Set Record = New ADODB.Recordset ConnStr = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" ConnStr = ConnStr & App.Path & "\" & "MyDB.mdb" Conn.ConnectionString = ConnStr '按照[连接字符串]的内容连接数据库 Conn.Open '连接