Dim adocon As Connection Dim adors As Recordset Dim strpath As String
strpath = ThisDrawing.Application.VBE.activevbproject.FileName Set adocon = New Connection adocon.CursorLocation = adUseClient '指定数据库路径,注意数据库名为工程名+cehuixiangmu.mdb, 和工程同在一个目录 adocon.Open "provider=microsoft.jet.oledb.4.0;data source=" & Left(strpath, Len(strpath) - 4) & "cehuixiangmu.mdb;" Set adors = New Recordset '数据库表名称为ptsten adors.Open "ptsten", adocon, adOpenDynamic, adLockOptimistic
'对数据库操作部分
'对数据库关闭部分 adors.Close adocon.Close |