请教:vba怎样与Access数据库联接??
<P>怎样用vba读取Access数据库中的数据??</P> 随便一本vba的书上都应该有阿,找本书看看吧 <P> Dim adocon As Connection<BR> Dim adors As Recordset<BR> Dim strpath As String</P><P><BR> strpath = ThisDrawing.Application.VBE.activevbproject.FileName<BR> Set adocon = New Connection<BR> adocon.CursorLocation = adUseClient<BR> '指定数据库路径,注意数据库名为工程名+cehuixiangmu.mdb, 和工程同在一个目录<BR> adocon.Open "provider=microsoft.jet.oledb.4.0;data source=" & Left(strpath, Len(strpath) - 4) & "cehuixiangmu.mdb;"<BR> Set adors = New Recordset<BR> '数据库表名称为ptsten<BR> adors.Open "ptsten", adocon, adOpenDynamic, adLockOptimistic</P>
<P> '对数据库操作部分</P>
<P> '对数据库关闭部分<BR> adors.Close<BR> adocon.Close</P>
页:
[1]