工程--->引用--->Microsoft ActiveX Data Object 2.x
public g_conn as new adodb.connection
Public Function link() As Boolean
link= False
On Error GoTo ErrHandler
With g_Conn
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + App.Path + "\xx.mdb;Persist Security Info=False" '数据库连接字符串
.CommandTimeout=15
.CursorLocation=adUseClient
.Open
End With
DBConnect = True
Exit Function
ErrHandler:
MsgBox "打开数据库连接失败,请检查数据文件是否存在!", vbOKOnly, "系统错误"
End Function