关于数据库联结问题
<P>在VBA中用下列语句连结数据库</P><P> Set conn = New ADODB.Connection<BR> conn.CursorLocation = adUseClient<BR> conn.Provider = "Microsoft.Jet.OLEDB.4.0;"<BR> connstr = "Data Surce=d:\制图\数据库\塔巴庙探井.mdb;"<BR> conn.Open connstr</P>
<P>但运行时出现错误如下:</P>
<P> Compile error:</P>
<P> Can't find project or library</P>
<P>我引用的是Microsoft ActiveX Data Objects 2.5 library</P>
<P>请问如何解决?非常感谢!</P> <P>菜单 工具 -〉引用-〉Micorsoft Access 11.0 Objects library 试试</P>
<P>Set Public conn As New ADODB.Connection '定义新连接<BR>Public cmd As New ADODB.Command '定义指令<BR>Public rs As New ADODB.Recordset '定义两个记录集</P>
<P>set conn = New Connection<BR>conn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=d:\制图\数据库\塔巴庙探井.mdb"<BR>Set cmd.ActiveConnection = conn<BR>cmd.CommandText = "select * from 表名"</P>
<P>rs.CursorLocation = adUseClient</P>
<P>rs.Open cmd, , adOpenStatic, adLockBatchOptimistic</P>
页:
[1]