查找数据表中是否已经包含指定的实体
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face="Times New Roman">VBA二次开发教程 第359页</FONT></P><P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face="Times New Roman">“' </FONT>查找数据表中是否已经包含指定的实体”</P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face="Times New Roman"></FONT> </P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face="Times New Roman">Private Sub FindObject(ByVal strDwgName As String, ByVal entHandle As String, ByVal strTable As String)</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face="Times New Roman"> mdlPubVariable.addMode = False</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face="Times New Roman"> </FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"><FONT face="Times New Roman">Dim rs As New ADODB.Recordset</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face="Times New Roman">rs.Open "SELECT EntHandle FROM " & strTable & " WHERE DwgName='" & strDwgName & "' AND EntHandle='" & entHandle & "';", _</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"><FONT face="Times New Roman"> adoCon, adOpenDynamic, adLockOptimistic</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"><FONT face="Times New Roman"> <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"><FONT face="Times New Roman">Debug.Print entHandle, strTable, strDwgName</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt">实体编号:<FONT face="Times New Roman">10E </FONT>表名:<FONT face="Times New Roman">School </FONT>文件名<FONT face="Times New Roman"> F:\..\Demo.dwg</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"><FONT face="Times New Roman">Debug.Print adoCon</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT face="Times New Roman">Degug.print</FONT>输出结果是<FONT face="Times New Roman"> Microsoft.Jet.OLEDB.4.0;Password="";User ID=Admin;Data Source=F:\..\Attribute.mdb;Mode=Share Deny None;Extended Properties="";Jet OLEDB:System database="";Jet OLEDB:Registry Path="";Jet OLEDB:Database Password="";Jet OLEDB:Engine Type=5;Jet OLEDB:Database Locking Mode=1;Jet OLEDB:Global Partial Bulk Ops=2;Jet OLEDB:Global Bulk Transactions=1;Jet OLEDB:New Database Password="";Jet OLEDB:Create System Database=False;Jet OLEDB:Encrypt Database=False;Jet OLEDB:Don't Copy Locale on Compact=False;Jet OLEDB:Compact Without Replica Repair=False;Jet OLEDB:SFP=False</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"><FONT face="Times New Roman"> <o:p></o:p></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT face="Times New Roman">Provider=Microsoft.Jet.OLEDB.4.0; </FONT>是否为调用<FONT face="Times New Roman">Access 2000</FONT>的引擎?<o:p></o:p></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT face="Times New Roman">Password="";</FONT>密码</P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT face="Times New Roman">User ID=Admin; </FONT>用户标识</P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT face="Times New Roman">Data Source=F:\..\Attribute.mdb;</FONT>数据文件</P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT face="Times New Roman">Mode=Share Deny None; </FONT>模式共享</P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT face="Times New Roman">Extended Properties="";Jet OLEDB:System database="";</FONT>扩展特征</P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT face="Times New Roman">Jet OLEDB:Registry Path="";Jet OLEDB:Database Password="";</FONT>引擎<FONT face="Times New Roman">???</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT face="Times New Roman">Jet OLEDB:Engine Type=5; </FONT>引擎<FONT face="Times New Roman">???</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT face="Times New Roman">Jet OLEDB:Database Locking Mode=1; </FONT>引擎<FONT face="Times New Roman">???</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT face="Times New Roman">Jet OLEDB:Global Partial Bulk Ops=2; </FONT>引擎<FONT face="Times New Roman">???</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT face="Times New Roman">Jet OLEDB:Global Bulk Transactions=1; </FONT>引擎<FONT face="Times New Roman">???</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT face="Times New Roman">Jet OLEDB:New Database Password=""; </FONT>引擎<FONT face="Times New Roman">???</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT face="Times New Roman">Jet OLEDB:Create System Database=False; </FONT>引擎<FONT face="Times New Roman">???</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT face="Times New Roman">Jet OLEDB:Encrypt Database=False; </FONT>引擎<FONT face="Times New Roman">???</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT face="Times New Roman">Jet OLEDB:Don't Copy Locale on Compact=False; </FONT>引擎<FONT face="Times New Roman">???</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT face="Times New Roman">Jet OLEDB:Compact Without Replica Repair=False; </FONT>引擎<FONT face="Times New Roman">???</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21pt; mso-char-indent-count: 2.0; mso-char-indent-size: 10.5pt"><FONT face="Times New Roman">Jet OLEDB:SFP=False </FONT>引擎<FONT face="Times New Roman">???</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"><FONT face="Times New Roman"> <o:p></o:p></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face="Times New Roman"> Debug.Print adOpenDynamic</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face="Times New Roman"> 2</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face="Times New Roman"> Debug.Print adLockOptimistic</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face="Times New Roman">3</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face="Times New Roman"> Debug.Print "SELECT EntHandle FROM " & strTable & " WHERE DwgName='" & strDwgName & "' AND EntHandle='" & entHandle & "';"</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face="Times New Roman">Degug.print </FONT>输出结果是<FONT face="Times New Roman">SELECT EntHandle FROM School WHERE DwgName='F:\.. \Demo.dwg' AND EntHandle='10E'; </FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face="Times New Roman"> </FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face="Times New Roman"> If rs.RecordCount <= 0 Then</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face="Times New Roman"> mdlPubVariable.addMode = True</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face="Times New Roman"> </FONT>查找整个工程也没有找到<FONT face="Times New Roman"> mdlPubVariable</FONT>的定义</P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face="Times New Roman"> End If</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"><FONT face="Times New Roman">rs.Close</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt">关闭数据库</P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face="Times New Roman">End Sub</FONT></P>
页:
[1]