兰州人 发表于 2006-7-22 18:02:00

查找数据表中是否已经包含指定的实体

<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>&nbsp;</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">&nbsp;&nbsp;&nbsp; mdlPubVariable.addMode = False</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face="Times New Roman">&nbsp;&nbsp;&nbsp; </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 " &amp; strTable &amp; " WHERE DwgName='" &amp; strDwgName &amp; "' AND EntHandle='" &amp; entHandle &amp; "';", _</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"><FONT face="Times New Roman">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; adoCon, adOpenDynamic, adLockOptimistic</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt; TEXT-INDENT: 21.75pt"><FONT face="Times New Roman">&nbsp;<?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">&nbsp;<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&nbsp; 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;&nbsp; </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;&nbsp; </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;&nbsp; </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;&nbsp; </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="";&nbsp; </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;&nbsp; </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;&nbsp; </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;&nbsp; </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&nbsp; </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">&nbsp;<o:p></o:p></FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face="Times New Roman">&nbsp;&nbsp;&nbsp; Debug.Print adOpenDynamic</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face="Times New Roman">&nbsp;&nbsp; 2</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face="Times New Roman">&nbsp;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">&nbsp;&nbsp;&nbsp; Debug.Print "SELECT EntHandle FROM " &amp; strTable &amp; " WHERE DwgName='" &amp; strDwgName &amp; "' AND EntHandle='" &amp; entHandle &amp; "';"</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';&nbsp;&nbsp; </FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face="Times New Roman">&nbsp;&nbsp;&nbsp; </FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face="Times New Roman">&nbsp;&nbsp;&nbsp; If rs.RecordCount &lt;= 0 Then</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face="Times New Roman">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; mdlPubVariable.addMode = True</FONT></P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face="Times New Roman">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </FONT>查找整个工程也没有找到<FONT face="Times New Roman">&nbsp; mdlPubVariable</FONT>的定义</P>
<P class=MsoNormal style="MARGIN: 0cm 0cm 0pt"><FONT face="Times New Roman">&nbsp;&nbsp;&nbsp; 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]
查看完整版本: 查找数据表中是否已经包含指定的实体