<?xml version="1.0" encoding="UTF-8"?>
  <feed xmlns="http://www.w3.org/2005/Atom">
  <title type="html"><![CDATA[accdb.net 独特诠释 access 2007 的新格式 *.accdb]]></title>
  <subtitle type="html"><![CDATA[不再自己写文章了，本站C# DELPHI 的文章都是摘抄自网络（除了明确署名的文章以外）。ERP财务类文章基本属于原创]]></subtitle>
  <id>http://www.accdb.net/</id> 
  <link rel="alternate" type="text/html" href="http://www.accdb.net/" /> 
  <link rel="self" type="application/atom+xml" href="http://www.accdb.net/atom.asp" /> 
  <generator uri="http://www.pjhome.net/" version="2.4.1022">PJBlog2</generator> 
  <updated>2012-02-06T00:11:50+08:00</updated> 

  <entry>
	  <title type="html"><![CDATA[VB6中使用32位图标(第二版)]]></title>
	  <author>
		 <name>陈格</name>
		 <uri>http://www.accdb.net/</uri>
		 <email>access911@gmail.com</email>
	  </author>
	  <category term="" scheme="http://www.accdb.net/default.asp?cateID=12" label="软件开发" /> 
	  <updated>2012-02-06T00:11:50+08:00</updated>
	  <published>2012-02-06T00:11:50+08:00</published>
		  <summary type="html"><![CDATA[ <br/>VB6中使用32位图标(第二版) .<br/>分类： Visual Basic 6.0 <br/><br/>第一版参见：<a href="http://blog.csdn.net/Modest/archive/2008/05/06/2399774.aspx" target="_blank">http://blog.csdn.net/Modest/archive/2008/05/06/2399774.aspx</a><br/><br/>本版添加了hIcon属性和SetFormIcon方法，顾名思义SetFormIcon就是实现vb6窗体的32位Icon应用。实现起来非常简单，发一个消息足矣。hIcon属性会根据图标索引返回图标句柄，用这个句柄还可以实现32位Icon在托盘中的美化应用。<br/>(声明：魏滔序原创，转贴请注明出处。)<br/><br/>全部代码如下：<br/><br/>&#39;::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::<br/>&#39;&nbsp;&nbsp;VB6中使用32位图标(第二版)<br/>&#39;&nbsp;&nbsp;Programmed by 魏滔序<br/>&#39;&nbsp;&nbsp;WebSite: <a href="http://www.chenoe.com" target="_blank">http://www.chenoe.com</a><br/>&#39;&nbsp;&nbsp;Blog: <a href="http://blog.csdn.net/Modest" target="_blank">http://blog.csdn.net/Modest</a><br/>&#39;:::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::<br/> <br/>Option Explicit<br/><br/>Private Type ICONDIRENTRY<br/>&nbsp;&nbsp;&nbsp;&nbsp;bWidth&nbsp;&nbsp;As Byte<br/>&nbsp;&nbsp;&nbsp;&nbsp;bHeight&nbsp;&nbsp;As Byte<br/>&nbsp;&nbsp;&nbsp;&nbsp;bColorCount&nbsp;&nbsp;As Byte<br/>&nbsp;&nbsp;&nbsp;&nbsp;bReserved&nbsp;&nbsp;As Byte<br/>&nbsp;&nbsp;&nbsp;&nbsp;wPlanes&nbsp;&nbsp;As Integer<br/>&nbsp;&nbsp;&nbsp;&nbsp;wBitCount&nbsp;&nbsp;As Integer<br/>&nbsp;&nbsp;&nbsp;&nbsp;dwBytesInRes&nbsp;&nbsp;As Long<br/>&nbsp;&nbsp;&nbsp;&nbsp;dwImageOffset&nbsp;&nbsp;As Long<br/>End Type<br/><br/>Private Type ICONDIR<br/>&nbsp;&nbsp;&nbsp;&nbsp;idReserved As Integer<br/>&nbsp;&nbsp;&nbsp;&nbsp;idType As Integer<br/>&nbsp;&nbsp;&nbsp;&nbsp;idCount As Integer<br/>&nbsp;&nbsp;&nbsp;&nbsp;idEntries() As ICONDIRENTRY<br/>End Type<br/><br/>Private Declare Function Cr&#101;ateIconFromResourceEx Lib &#34;user32&#34; (presbits As Byte, ByVal dwResSize As Long, ByVal fIcon As Long, ByVal dwVer As Long, ByVal cxDesired As Long, ByVal cyDesired As Long, ByVal uFlags As Long) As Long<br/>Private Declare Function DrawIconEx Lib &#34;user32.dll&#34; (ByVal hdc As Long, ByVal xLeft As Long, ByVal yTop As Long, ByVal hIcon As Long, ByVal cxWidth As Long, ByVal cyWidth As Long, ByVal istepIfAniCur As Long, ByVal hbrFlickerFreeDraw As Long, ByVal diFlags As Long) As Long<br/>Private Declare Function DestroyIcon Lib &#34;user32&#34; (ByVal hIcon As Long) As Long<br/>Private Declare Sub CopyMemory Lib &#34;kernel32.dll&#34; Alias &#34;RtlMoveMemory&#34; (ByRef Destination As Any, ByRef Source As Any, ByVal Length As Long)<br/>Private Declare Function SendMessageLong Lib &#34;user32&#34; Alias &#34;SendMessageA&#34; (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long<br/><br/>Private m_Data() As Byte<br/>Private m_iCount As Integer<br/>Private m_iDir As ICONDIR<br/><br/>Public Property Get Count() As Long<br/>&nbsp;&nbsp;&nbsp;&nbsp;Count = m_iCount<br/>End Property<br/><br/>Public Property Get Height(Optional ByVal Index As Long) As Long<br/>&nbsp;&nbsp;&nbsp;&nbsp;Height = m_iDir.idEntries(Index).bHeight<br/>End Property<br/><br/>Public Property Get Width(Optional ByVal Index As Long) As Long<br/>&nbsp;&nbsp;&nbsp;&nbsp;Width = m_iDir.idEntries(Index).bWidth<br/>End Property<br/><br/>Public Property Get Length(Optional ByVal Index As Long) As Long<br/>&nbsp;&nbsp;&nbsp;&nbsp;Length = m_iDir.idEntries(Index).dwBytesInRes<br/>End Property<br/><br/>Public Property Get Data(Optional ByVal Index As Long) As Byte()<br/>&nbsp;&nbsp;&nbsp;&nbsp;Dim o As Long, l As Long, d() As Byte<br/>&nbsp;&nbsp;&nbsp;&nbsp;o = m_iDir.idEntries(Index).dwImageOffset<br/>&nbsp;&nbsp;&nbsp;&nbsp;l = m_iDir.idEntries(Index).dwBytesInRes<br/>&nbsp;&nbsp;&nbsp;&nbsp;ReDim d(l - 1)<br/>&nbsp;&nbsp;&nbsp;&nbsp;CopyMemory d(0), m_Data(o), l<br/>&nbsp;&nbsp;&nbsp;&nbsp;Data = d<br/>End Property<br/><br/>Public Function LoadFromData(Data() As Byte) As Boolean<br/>&nbsp;&nbsp;&nbsp;&nbsp;Dim i As Long<br/>&nbsp;&nbsp;&nbsp;&nbsp;m_Data = Data<br/>&nbsp;&nbsp;&nbsp;&nbsp;CopyMemory m_iCount, m_Data(4), 2&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#39;取得图标个数<br/>&nbsp;&nbsp;&nbsp;&nbsp;If m_iCount &gt; 0 Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ReDim m_iDir.idEntries(0 To m_iCount - 1)&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&#39;图标目录结构数据<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;For i = 0 To m_iCount - 1<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;CopyMemory m_iDir.idEntries(i), m_Data(6 + Len(m_iDir.idEntries(i)) * i), Len(m_iDir.idEntries(i))<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Next<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;LoadFromData = True<br/>&nbsp;&nbsp;&nbsp;&nbsp;End If<br/>End Function<br/><br/>Public Function LoadFromFile(ByVal FileName As String) As Boolean<br/>&nbsp;&nbsp;&nbsp;&nbsp;Dim hFile As Integer<br/>&nbsp;&nbsp;&nbsp;&nbsp;Dim Data() As Byte<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;If Dir(FileName) = &#34;&#34; Then Exit Function<br/>&nbsp;&nbsp;&nbsp;&nbsp;<br/>&nbsp;&nbsp;&nbsp;&nbsp;hFile = FreeFile<br/>&nbsp;&nbsp;&nbsp;&nbsp;Open FileName For Binary As #hFile<br/>&nbsp;&nbsp;&nbsp;&nbsp;ReDim Data(LOF(hFile) - 1)<br/>&nbsp;&nbsp;&nbsp;&nbsp;Get #hFile, , Data<br/>&nbsp;&nbsp;&nbsp;&nbsp;Close #hFile<br/><br/>&nbsp;&nbsp;&nbsp;&nbsp;LoadFromFile = LoadFromData(Data)<br/>End Function<br/><br/>Public Property Get hIcon(Optional ByVal Index As Long) As Long<br/>&nbsp;&nbsp;&nbsp;&nbsp;Dim d() As Byte, l As Long, w As Long, h As Long<br/>&nbsp;&nbsp;&nbsp;&nbsp;d = Data(Index): l = Length(Index)<br/>&nbsp;&nbsp;&nbsp;&nbsp;w = Width(Index): h = Height(Index)<br/>&nbsp;&nbsp;&nbsp;&nbsp;hIcon = Cr&#101;ateIconFromResourceEx(d(0), l, 1, &amp;H30000, w, h, 0)<br/>End Property<br/><br/>Public Function Draw(ByVal hdc As Long, ByVal x As Long, ByVal y As Long, Optional ByVal Index As Long = 0) As Boolean<br/>&nbsp;&nbsp;&nbsp;&nbsp;Dim w As Long, h As Long<br/>&nbsp;&nbsp;&nbsp;&nbsp;w = Width(Index): h = Height(Index)<br/>&nbsp;&nbsp;&nbsp;&nbsp;Draw = DrawIconEx(hdc, x, y, hIcon(Index), w, h, 0, 0, 3) &lt;&gt; 0<br/>&nbsp;&nbsp;&nbsp;&nbsp;DestroyIcon hIcon<br/>End Function<br/><br/>Public Sub SetFormIcon(ByVal Form As Form, Optional ByVal Index As Long = 0)<br/>&nbsp;&nbsp;&nbsp;&nbsp;SendMessageLong Form.hWnd, &amp;H80, 0, hIcon(Index)<br/>End Sub<br/><br/>Private Sub Class_Terminate()<br/>&nbsp;&nbsp;&nbsp;&nbsp;Erase m_Data<br/>End Sub]]></summary>
	  <link rel="alternate" type="text/html" href="http://www.accdb.net/default.asp?id=1807" /> 
	  <id>http://www.accdb.net/default.asp?id=1807</id> 
  </entry>	
		
  <entry>
	  <title type="html"><![CDATA[SQL server 中 取出分组后每组的前几条]]></title>
	  <author>
		 <name>陈格</name>
		 <uri>http://www.accdb.net/</uri>
		 <email>access911@gmail.com</email>
	  </author>
	  <category term="" scheme="http://www.accdb.net/default.asp?cateID=12" label="软件开发" /> 
	  <updated>2012-01-29T13:38:38+08:00</updated>
	  <published>2012-01-29T13:38:38+08:00</published>
		  <summary type="html"><![CDATA[分组取前几<br/><br/>SQL server 中 取出分组后每组的前几条<br/><br/>作者：Rex.He&nbsp;&nbsp;来源：博客园&nbsp;&nbsp;发布时间：2011-09-14 16:00&nbsp;&nbsp;阅读：25 次&nbsp;&nbsp;原文链接&nbsp;&nbsp; [收藏]&nbsp;&nbsp; <br/>表:T <br/>字段:id&nbsp;&nbsp; 自动递增, <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;field1&nbsp;&nbsp; 数字, <br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;..... <br/>sel&#101;ct&nbsp;&nbsp; *&nbsp;&nbsp; from&nbsp;&nbsp; ( <br/>sel&#101;ct&nbsp;&nbsp; *,(sel&#101;ct&nbsp;&nbsp; count(*)&nbsp;&nbsp; from&nbsp;&nbsp; T&nbsp;&nbsp; as&nbsp;&nbsp; t2&nbsp;&nbsp; wh&#101;re&nbsp;&nbsp; t2.field1=t1.field1&nbsp;&nbsp; and&nbsp;&nbsp; t2.id &lt;=t1.id)&nbsp;&nbsp; as&nbsp;&nbsp; aaa&nbsp;&nbsp; from&nbsp;&nbsp; T&nbsp;&nbsp; as&nbsp;&nbsp; t1)&nbsp;&nbsp; as&nbsp;&nbsp; t3 <br/>wh&#101;re&nbsp;&nbsp; aaa &lt;=2t2.field1=t1.field1是分组的条件，可自由添加<br/><br/>参考地址：<br/><br/><a href="http://topic.csdn.net/t/20040819/17/3291042.html" target="_blank">http://topic.csdn.net/t/20040819/17/3291042.html</a> <br/><br/> <br/><br/> <br/><br/>取出数据中每个分类前5条<br/><br/> <br/><br/>sel&#101;ct ID,title,D_Picture,addtime,newstypeid,jj,content<br/> FROM news ns<br/> wh&#101;re ID in (sel&#101;ct top 5 ID from news wh&#101;re newstypeid = ns.newstypeid and isActive=&#39;1&#39; o&#114;der by addtime desc)&nbsp;&nbsp;]]></summary>
	  <link rel="alternate" type="text/html" href="http://www.accdb.net/default.asp?id=1806" /> 
	  <id>http://www.accdb.net/default.asp?id=1806</id> 
  </entry>	
		
  <entry>
	  <title type="html"><![CDATA[XML Data Manipulation with ADO 2.5]]></title>
	  <author>
		 <name>陈格</name>
		 <uri>http://www.accdb.net/</uri>
		 <email>access911@gmail.com</email>
	  </author>
	  <category term="" scheme="http://www.accdb.net/default.asp?cateID=12" label="软件开发" /> 
	  <updated>2012-01-23T00:17:57+08:00</updated>
	  <published>2012-01-23T00:17:57+08:00</published>
		  <summary type="html"><![CDATA[<p><b>XML Data Manipulation with ADO 2.5</b> </p>
<p>Ken Spencer</p>
<p><b>Code for this article:</b> Serving0800.exe (33KB) </p>
<table align="left">
    <tbody>
        <tr>
            <td><span style="FONT-FAMILY: verdana, artial, helv; COLOR: #cc3300; FONT-SIZE: 18pt"><b>I</b></span> </td>
        </tr>
    </tbody>
</table>
recently discovered some features of ActiveX&Acirc;&reg; Data Objects (ADO) 2.5 that make it easier to use XML and your data source in your Web applications. I was working on Internet and intranet apps that run on Windows&Acirc;&reg; 2000, so I could take advantage of ADO 2.5 to make data manipulation easier. Let's take a look at the benefits of ADO 2.5 that I found in my research and how I dealt with some of the problems you may encounter.
<h3>XML Streams</h3>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ADO 2.5 includes some helpful support for XML. In this version of ADO you can save a recordset as an XML stream. This allows you to simply save the recordset, and voil&iuml;&iquest;&frac12;&acirc;&euro;&quot;you have an XML stream to work with. While it's easy to create the XML stream, the downside is that you are stuck with the XML schema that ADO generates. You can't tweak it to your liking or to any other format; you can either use the standard ADO format or roll your own (more on that in a minute).<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The way you save a recordset to a stream is simple. Just use the Save method of the recordset and specify the adPersistXML option, like so:
<table>
    <tbody>
        <tr>
            <td>
            <pre><code>
            rstCustomers.save &quot;MyXMLFile.xml&quot;, adPersistXML
            </code></pre>
            </td>
        </tr>
    </tbody>
</table>
This method saves the rstCustomers recordset as an XML file. Once you have saved it, you can open the file in Microsoft&Acirc;&reg; Internet Explorer, ADO, or any other application that can load an XML file and parse it. So far, so good. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;When you save the recordset like this, the format is quite complex and follows the ADO XML schema I mentioned earlier. <a id="ctl00_MTContentSelector1_mainContentContainer_ctl02" onclick="javascript:Track('ctl00_MTContentSelector1_mainContentContainer_ctl00|ctl00_MTContentSelector1_mainContentContainer_ctl02',this);" href="http://msdn.microsoft.com/en-us/magazine/bb985058.aspx">Figure&nbsp;1</a> shows the results of saving the Titles table from an ADO recordset to an XML file. The data shown in <a id="ctl00_MTContentSelector1_mainContentContainer_ctl03" onclick="javascript:Track('ctl00_MTContentSelector1_mainContentContainer_ctl00|ctl00_MTContentSelector1_mainContentContainer_ctl03',this);" href="http://msdn.microsoft.com/en-us/magazine/bb985058.aspx">Figure&nbsp;1</a> is the Document Type Definition (DTD) for the XML generated by ADO. The data starts with the rs:data element shown in <a id="ctl00_MTContentSelector1_mainContentContainer_ctl04" onclick="javascript:Track('ctl00_MTContentSelector1_mainContentContainer_ctl00|ctl00_MTContentSelector1_mainContentContainer_ctl04',this);" href="http://msdn.microsoft.com/en-us/magazine/bb985058.aspx">Figure&nbsp;2</a>.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;My major complaint about the way the XML is generated has to do with its structure. Since it is generic, the schema uses generic namespaces (such as rs) to contain the actual data. Then each record is output with its data going into attributes instead of tag elements or being split into tag elements and attributes.
<h3>The Sample Apps</h3>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Now let's look at another way of using XML with ADO. The MSDN&Acirc;&reg; library reference for the ADO Recordset Save method shows the following example:
<table>
    <tbody>
        <tr>
            <td>
            <pre><code>
            Dim xDOM As New MSXML.DOMDocument
            Dim rsXML As New ADODB.Recordset
            Dim sSQL As String, sConn As String
            sSQL = &quot;Select customerid, companyname, contactname
            FROM customers&quot;
            sConn= &amp; _  &quot;Provider=Microsoft.Jet.OLEDB.4.0;
            Data Source=D:\Program Files&quot; &amp; _
            &quot;\Common Files\System\msadc\samples\NWind.mdb&quot;
            rsXML.Open sSQL, sConn
            rsXML.Save xDOM, adPersistXML
            </code></pre>
            </td>
        </tr>
    </tbody>
</table>
The reference says that this example will save the recordset in an XML tree in the object referenced by xDOM. This is all well and good, but the sample does not work. (I tried this on Windows 2000 Professional.) But all is not lost.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;I created the following code sample, which uses the new Stream object from ADO 2.5:
<table>
    <tbody>
        <tr>
            <td>
            <pre><code>
            Function RetrieveAllTitlesAsXML() As Variant
            Dim stXMLStream As Stream
            Set rsAllTitles = New ADODB.Recordset
            Set stXMLStream = New Stream
            sSQL = &quot;select * from titles&quot;
            rsAllTitles.Open sSQL, GetDSN, _
            adOpenForwardOnly, adLockReadOnly, adCmdText
            rsAllTitles.save stXMLStream, adPersistXML
            rsAllTitles.Close
            Set rsAllTitles = Nothing
            Set RetrieveAllTitlesAsXML = stXMLStream
            End Function
            </code></pre>
            </td>
        </tr>
    </tbody>
</table>
The first line in this procedure dimensions the stXMLStream variable as a Stream object. It then creates a new instance of the ADO Recordset object, followed by an instance of the Stream object. Next, it sets the SQL for the Open method and executes Open to retrieve the records. The next line saves the recordset to the Stream object in XML format by specifying the stXMLStream variable as the first argument to the Save method, then specifying the adPersistXML constant as the last argument. The next two lines close the recordset and set the recordset variable to &quot;Nothing&quot;. The last line returns the Stream object as the return variable from the function. At this point the calling application has access to the Stream object. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Now let's look at code that uses the Stream object that is returned from the RetrieveAllTitlesAsXML function:
<table>
    <tbody>
        <tr>
            <td>
            <pre><code>
            Dim stXMLStream As Stream
            Set objPub = New
            Publication.Title
            Set stXMLStream = objPub.RetrieveAllTitlesAsXML()
            txtNotes.Text =
            stXMLStream.ReadText()
            </code></pre>
            </td>
        </tr>
    </tbody>
</table>
The first line creates a variable and defines it as type Stream just like the RetrieveAllTitlesAsXML method. The next line instantiates the Title object, and the following line executes RetrieveAllTitlesAsXML and sets the return value to the stXMLStream variable. The last line extracts the XML from the Stream object by executing the ReadText method of the Stream object.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;So far, you have seen how to create the Stream object, populate it with a recordset, and extract the XML from the Stream object for that recordset, as shown in the following code:
<table>
    <tbody>
        <tr>
            <td>
            <pre><code>
            sXML = stXMLStream.ReadText()
            xmlDoc.loadXML (sXML)
            </code></pre>
            </td>
        </tr>
    </tbody>
</table>
This code loads the sXML variable from the Stream object into the sXML variable. Then the LoadXML method of the MSXML.DOMDocument loads the string into the MSXML parser's document object. Now you can work with it just like any other XML. The Stream object serves as a way to move the XML from the Recordset object into the parser document object. I'll come back to the parser in a minute.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The ADO documents point out that you can save the recordset to the Response object in your ASP code. The sample code shown in the MSDN library looks like this:
<table>
    <tbody>
        <tr>
            <td>
            <pre><code>
            Response.Write &quot;&lt;?xml version='1.0' encoding='ISO-8859-1'?&gt;&quot; _
            &amp; vbCRLF
            rstCustomers.save Response, adPersistXML
            rstCustomers.Close
            </code></pre>
            </td>
        </tr>
    </tbody>
</table>
This code generates XML from the recordset and sends it down the wire to the browser (or other calling application), where you can use the MSXML parser in Internet Explorer or any other XML engine to work with the data.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Now let's get back to the MSXML parser and other ways of generating and using XML. I have written about a small XML class in past columns. I used this code to create a class called Generator (Generator.cls in XMLGen.vbp) for this column. This class is really useful for formatting XML that you use in other applications. The code in <a id="ctl00_MTContentSelector1_mainContentContainer_ctl05" onclick="javascript:Track('ctl00_MTContentSelector1_mainContentContainer_ctl00|ctl00_MTContentSelector1_mainContentContainer_ctl05',this);" href="http://msdn.microsoft.com/en-us/magazine/bb985058.aspx">Figure&nbsp;3</a> is from the Title class in the Publications.vbp project's RetrieveTitlesSimpleXML method, which extracts data from the Titles table in the Pubs database, and then returns the data in an XML string.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The first thing the code in <a id="ctl00_MTContentSelector1_mainContentContainer_ctl06" onclick="javascript:Track('ctl00_MTContentSelector1_mainContentContainer_ctl00|ctl00_MTContentSelector1_mainContentContainer_ctl06',this);" href="http://msdn.microsoft.com/en-us/magazine/bb985058.aspx">Figure&nbsp;3</a> does is create an instance of the XML utility:
<table>
    <tbody>
        <tr>
            <td>
            <pre><code>
            Set oXML = New Generator
            </code></pre>
            </td>
        </tr>
    </tbody>
</table>
It creates an instance of the ADO Recordset object, then calls the XMLDeclaration method to output the XML declaration at the start of my XML stream:
<table>
    <tbody>
        <tr>
            <td>
            <pre><code>
            vOutPut = oXML.XMLDeclaration()
            </code></pre>
            </td>
        </tr>
    </tbody>
</table>
The BeginTag method is called to create the starting Books tag:
<table>
    <tbody>
        <tr>
            <td>
            <pre><code>
            vOutPut = vOutPut &amp; oXML.BeginTag(&quot;Books&quot;)
            </code></pre>
            </td>
        </tr>
    </tbody>
</table>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The Do...While loop processes the recordset. The Format method of the XML utility is called for each field in a record. This method takes the tag name and the value (from the recordset). It returns the properly formatted tag for that field and puts it into the vOutput variable.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The only really tricky part of this code is the call to BeginTag in the loop:
<table>
    <tbody>
        <tr>
            <td>
            <pre><code>
            sBeginTag = oXML.BeginTag(&quot;Book&quot;, &quot;TitleID&quot;, rsTitle(&quot;title_id&quot;))
            </code></pre>
            </td>
        </tr>
    </tbody>
</table>
The BeginTag method takes two optional parameters, an attribute name and an attribute value. That lets you format a tag and add an attribute at the same time. This results in a tag that looks something like the following:
<table>
    <tbody>
        <tr>
            <td>
            <pre><code>
            &lt;Book TitleID=&quot;BU1032&quot;&gt;
            </code></pre>
            </td>
        </tr>
    </tbody>
</table>
The EndTag method is called twice, once to end the Book tag each time through the loop and once to end the Books parent tag at the end of the procedure. Then the procedure returns the entire string as its return value.<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The XMLParser code is shown in <a id="ctl00_MTContentSelector1_mainContentContainer_ctl07" onclick="javascript:Track('ctl00_MTContentSelector1_mainContentContainer_ctl00|ctl00_MTContentSelector1_mainContentContainer_ctl07',this);" href="http://msdn.microsoft.com/en-us/magazine/bb985058.aspx">Figure&nbsp;4</a>. The Parse method is not used in this application; it is simply left over from previous projects. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The Visual Basic-created form in <b>Figure&nbsp;5</b> is used to test the XML functionality that I have been discussing. To test the RetrieveTitlesSimpleXML method, click the Retrieve XML into MSXML button. This button calls the RetrieveTitlesSimple-XML method in Title, then uses the MSXML parser to read the XML stream.<br />
<table>
    <tbody>
        <tr>
            <td><img alt="Figure 5 Testing the XML" src="http://i.msdn.microsoft.com/Bb985051.servingfig080005(en-us,MSDN.10).gif" width="360" height="256" /></td>
        </tr>
        <tr>
            <td><b>Figure 5</b> <b>Testing the XML</b> </td>
        </tr>
    </tbody>
</table>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;The code from the cmdXMLIntoMSXML event is shown in <a id="ctl00_MTContentSelector1_mainContentContainer_ctl08" onclick="javascript:Track('ctl00_MTContentSelector1_mainContentContainer_ctl00|ctl00_MTContentSelector1_mainContentContainer_ctl08',this);" href="http://msdn.microsoft.com/en-us/magazine/bb985058.aspx">Figure&nbsp;6</a>. Most of the declarations at the beginning of the procedure define variables that will be used with the MSXML parser. The first two set statements instantiate the Title class and the DOMDocu-ment class: </p>
<table>
    <tbody>
        <tr>
            <td>
            <pre><code>
            Set objPub = New Publication.Title
            Set xmlDoc = New MSXML.DOMDocument
            </code></pre>
            </td>
        </tr>
    </tbody>
</table>
Then the RetrieveTitlesSimpleXML method is executed and returns the XML stream into the sXML variable:
<table>
    <tbody>
        <tr>
            <td>
            <pre><code>
            sXML = objPub.RetrieveTitlesSimpleXML()
            </code></pre>
            </td>
        </tr>
    </tbody>
</table>
The next line of code loads the sNodeToFind variable with the value Book:
<table>
    <tbody>
        <tr>
            <td>
            <pre><code>
            sNodeToFind = &quot;Book&quot;
            </code></pre>
            </td>
        </tr>
    </tbody>
</table>
If you look back at <a id="ctl00_MTContentSelector1_mainContentContainer_ctl09" onclick="javascript:Track('ctl00_MTContentSelector1_mainContentContainer_ctl00|ctl00_MTContentSelector1_mainContentContainer_ctl09',this);" href="http://msdn.microsoft.com/en-us/magazine/bb985058.aspx">Figure&nbsp;3</a> you'll see that I created Book as the element tag for each title I retrieve. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Next, the code sets the async property of the MSXML DOMDocument object to False. If this is not set to False, the XML will be loaded asynchronously and you must check the readyState property to determine when the XML has been loaded.
<table>
    <tbody>
        <tr>
            <td>
            <pre><code>
            xmlDoc.async = False
            </code></pre>
            </td>
        </tr>
    </tbody>
</table>
Then the LoadXML method is called to actually load the XML from my string (sXML):
<table>
    <tbody>
        <tr>
            <td>
            <pre><code>
            xmlDoc.loadXML (sXML)
            </code></pre>
            </td>
        </tr>
    </tbody>
</table>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Now you can work with the XML document through the methods of the MSXML DOMDocument object. The next line of code finds the Book tags and returns an object representing a node list for all of those tags:
<table>
    <tbody>
        <tr>
            <td>
            <pre><code>
            Set objNodeList = xmlDoc.getElementsByTagName(sNodeToFind)
            </code></pre>
            </td>
        </tr>
    </tbody>
</table>
The For...Next loop loops through all of the tags in the node list:
<table>
    <tbody>
        <tr>
            <td>
            <pre><code>
            For i = 0 To (objNodeList.length - 1)
            </code></pre>
            </td>
        </tr>
    </tbody>
</table>
The NextNode method returns a Node object for the next tag in the list:
<table>
    <tbody>
        <tr>
            <td>
            <pre><code>
            Set objNode = objNodeList.nextNode
            </code></pre>
            </td>
        </tr>
    </tbody>
</table>
The Attributes method extracts the attributes for the current node and places them into a NodeMap object:
<table>
    <tbody>
        <tr>
            <td>
            <pre><code>
            Set objNodeMap = objNode.Attributes
            </code></pre>
            </td>
        </tr>
    </tbody>
</table>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Now you can finally get to the attribute. The following code extracts the attribute named TitleID and sets it in a Node object:
<table>
    <tbody>
        <tr>
            <td>
            <pre><code>
            Set objNamedItem = objNodeMap.getNamedItem(&quot;TitleID&quot;)
            </code></pre>
            </td>
        </tr>
    </tbody>
</table>
The next lines of code extract the attribute text and the text from the node:
<table>
    <tbody>
        <tr>
            <td>
            <pre><code>
            txtNotes = txtNotes &amp; objNamedItem.Text &amp; &quot;  -  &quot;
            txtNotes = txtNotes &amp; objNode.Text &amp; vbCrLf
            </code></pre>
            </td>
        </tr>
    </tbody>
</table>
The last few lines of code in the procedure clean up the loop and destroy the objects. When you run this procedure, the results look like <b>Figure&nbsp;7</b>. <br />
<table>
    <tbody>
        <tr>
            <td><img alt="Figure 7 The Results" src="http://i.msdn.microsoft.com/Bb985051.servingfig080007(en-us,MSDN.10).gif" width="360" height="256" /></td>
        </tr>
        <tr>
            <td><b>Figure 7</b> <b>The Results</b> </td>
        </tr>
    </tbody>
</table>
<h3>Conclusion</h3>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;It can be difficult to decide if you should use XML in your project. First, you must figure out where it really makes sense to use XML. It does not solve every problem, and it is not suitable for every instance of an application that you build. It is also sometimes difficult to figure out how to work with XML. I am not a big fan of creating extra work for myself, so I always create classes like Generator to standardize the work for me. That makes my life easy because it provides a tool to work with and simplifies my interface to the technology. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;You can experiment with my sample application to create other ways of working with XML. The Simple Stream button will pull data from the database and put it into XML, then load the XML into Form2. Form2 calls the MSXML parser to parse the XML and load the data into the form. The sample code is really designed to explore different ways of working with XML using ADO and the MSXML parser. It's handy because you can cut and paste that code into your components or ASP script to add functionality to your own applications. <br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;There is also lots more to look forward to with XML. The BizTalk&acirc;&bdquo;&cent; framework and other initiatives make it vital to understand XML and how it works so you can communicate with other applications. <br /><br /><i><b>Ken Spencer</b> works for the 32X Tech Corporation (<a id="ctl00_MTContentSelector1_mainContentContainer_ctl10" onclick="javascript:Track('ctl00_MTContentSelector1_mainContentContainer_ctl00|ctl00_MTContentSelector1_mainContentContainer_ctl10',this);" href="http://www.32x.com/">http://www.32X.com</a>), which produces a line of high-quality developer courseware. Ken also spends much of his time consulting or teaching private courses.</i><br />
<p><i>From the August 2000 issue of MSDN Magazine</i></p>
<p><em></em></p>
<p><em></em></p>
<p><a href="http://msdn.microsoft.com/en-us/magazine/bb985051.aspx">http://msdn.microsoft.com/en-us/magazine/bb985051.aspx</a></p>]]></summary>
	  <link rel="alternate" type="text/html" href="http://www.accdb.net/default.asp?id=1805" /> 
	  <id>http://www.accdb.net/default.asp?id=1805</id> 
  </entry>	
		
  <entry>
	  <title type="html"><![CDATA[高效SQL——合并多个字段值或多条记录]]></title>
	  <author>
		 <name>陈格</name>
		 <uri>http://www.accdb.net/</uri>
		 <email>access911@gmail.com</email>
	  </author>
	  <category term="" scheme="http://www.accdb.net/default.asp?cateID=12" label="软件开发" /> 
	  <updated>2012-01-14T21:34:37+08:00</updated>
	  <published>2012-01-14T21:34:37+08:00</published>
		  <summary type="html"><![CDATA[<div class="articleTitle">
<h1><a href="http://www.accdb.net/#">高效SQL&mdash;&mdash;合并多个字段值或多条记录</a></h1>
<div class="dots"><!--<span>字号：<b class="font14" title="小字号">T</b>|<b class="font16 blue" title="大字号">T</b></span>--></div>
</div>
<div id="digest">
<p>为什么说是高效呢?因为摒弃了游标和函数的途径，而采用变量的方式来保存值。也就是说避免了游标和函数自身的缺点。 </p>
</div>
<div id="artibody">
<div id="content" class="content">
<div class="guanggao"><span id="contentAdv"><!-- Error --></span></div>
<p>　　<strong>高效SQL&mdash;&mdash;从无主键表中合并字段值</strong></p>
<p>&nbsp;</p>
<table style="BORDER-BOTTOM: #cccccc 1px dotted; BORDER-LEFT: #cccccc 1px dotted; TABLE-LAYOUT: fixed; BORDER-TOP: #cccccc 1px dotted; BORDER-RIGHT: #cccccc 1px dotted" border="0" cellspacing="0" cellpadding="6" width="95%" align="center">
    <tbody>
        <tr>
            <td style="WORD-WRAP: break-word" bgcolor="#f3f3f3"><font style="COLOR: #990000; FONT-WEIGHT: bold">以下是引用片段：</font><br />　　create&nbsp;table&nbsp;#T1 <br />　　( <br />　　A&nbsp;varchar(10), <br />　　B&nbsp;varchar(20) <br />　　) <br />　　insert&nbsp;into&nbsp;#T1&nbsp;values&nbsp;('aa','1') <br />　　insert&nbsp;into&nbsp;#T1&nbsp;values&nbsp;('aa','9a') <br />　　insert&nbsp;into&nbsp;#T1&nbsp;values&nbsp;('bb','1') <br />　　insert&nbsp;into&nbsp;#T1&nbsp;values&nbsp;('bb','10') <br />　　insert&nbsp;into&nbsp;#T1&nbsp;values&nbsp;('bb','16') <br />　　insert&nbsp;into&nbsp;#T1&nbsp;values&nbsp;('aa','16') <br />　　insert&nbsp;into&nbsp;#T1&nbsp;values&nbsp;('aa','17') <br />　　insert&nbsp;into&nbsp;#T1&nbsp;values&nbsp;('aa','30') <br />　　insert&nbsp;into&nbsp;#T1&nbsp;values&nbsp;('bb','6df') <br />　　insert&nbsp;into&nbsp;#T1&nbsp;values&nbsp;('aa','5') <br />　　insert&nbsp;into&nbsp;#T1&nbsp;values&nbsp;('aa','8') <br />　　insert&nbsp;into&nbsp;#T1&nbsp;values&nbsp;('aa','ed')</td>
        </tr>
    </tbody>
</table>
<p>&nbsp;</p>
<p>　　所要的结果：</p>
<p>　　aa 1,9a,16,17,30,5,8,ed</p>
<p>　　bb 1,10,16,6df</p>
<p>　　解决方法：</p>
<p>&nbsp;</p>
<table style="BORDER-BOTTOM: #cccccc 1px dotted; BORDER-LEFT: #cccccc 1px dotted; TABLE-LAYOUT: fixed; BORDER-TOP: #cccccc 1px dotted; BORDER-RIGHT: #cccccc 1px dotted" border="0" cellspacing="0" cellpadding="6" width="95%" align="center">
    <tbody>
        <tr>
            <td style="WORD-WRAP: break-word" bgcolor="#f3f3f3"><font style="COLOR: #990000; FONT-WEIGHT: bold">以下是引用片段：</font><br />　　declare&nbsp;@c&nbsp;varchar(1024) <br />　　set&nbsp;@c='' <br />　　declare&nbsp;@x&nbsp;char(10),@y&nbsp;char(10) <br />　　set&nbsp;@x='' <br />　　set&nbsp;@y='' <br />　　select&nbsp;@y=@x,@x=x.a,@c=@c&nbsp;+&nbsp;(case&nbsp;@x&nbsp;when&nbsp;@y&nbsp;then&nbsp;','&nbsp;else&nbsp;';'&nbsp;+&nbsp;x.a&nbsp;+&nbsp;':'&nbsp;end) <br />　　+x.d&nbsp;from&nbsp;(select&nbsp;b&nbsp;as&nbsp;d,a&nbsp;from&nbsp;#t1)&nbsp;as&nbsp;x&nbsp;order&nbsp;by&nbsp;x.a <br />　　set&nbsp;@c=substring(@c,2,len(@c)-1) <br />　　select&nbsp;@c</td>
        </tr>
    </tbody>
</table>
<p>&nbsp;</p>
<p>　　为什么说是高效呢?</p>
<p>　　因为摒弃了游标和函数的途径，而采用变量的方式来保存值</p>
<p>　　也就是说避免了游标和函数自身的缺点</p>
<p>　　<strong>如果是简单地把字段值合并的sql语句：</strong></p>
<p>　　select c1||c2||c3 as name from table</p>
<p>　　中间可以添加字符常量和数字，如</p>
<p>　　select c1||'test'||c2||c3 as name from table</p>
<p>　　select c1||2||c2||c3 as name from table</p>
<p>　　如何用一条SQL语句，将多条记录(一个字段)合并为一个?</p>
<p>　　例如：</p>
<p>　　table字段为：tableID(nchar)</p>
<p>　　查询结果为不确定的多条：</p>
<p>　　tableID</p>
<p>　　T1</p>
<p>　　T2</p>
<p>　　T3</p>
<p>　　T4</p>
<p>　　&hellip;&hellip;</p>
<p>　　<strong>如何用一条SQL语句将这些记录合并为一个字段，值为：'T1T2T3&hellip;&hellip;'</strong></p>
<p>&nbsp;</p>
<table style="BORDER-BOTTOM: #cccccc 1px dotted; BORDER-LEFT: #cccccc 1px dotted; TABLE-LAYOUT: fixed; BORDER-TOP: #cccccc 1px dotted; BORDER-RIGHT: #cccccc 1px dotted" border="0" cellspacing="0" cellpadding="6" width="95%" align="center">
    <tbody>
        <tr>
            <td style="WORD-WRAP: break-word" bgcolor="#f3f3f3"><font style="COLOR: #990000; FONT-WEIGHT: bold">以下是引用片段：</font><br />　　create&nbsp;table&nbsp;t <br />　　(tableid&nbsp;nchar(30)) <br />　　insert&nbsp;t <br />　　select&nbsp;'T1'&nbsp;union&nbsp;all <br />　　select&nbsp;'T2'&nbsp;union&nbsp;all <br />　　select&nbsp;'T3'&nbsp;union&nbsp;all <br />　　select&nbsp;'T4'&nbsp;union&nbsp;all <br />　　select&nbsp;'T5'&nbsp;union&nbsp;all <br />　　select&nbsp;'T6' <br />　　go <br />　　create&nbsp;function&nbsp;f_he() <br />　　returns&nbsp;@t&nbsp;table(col&nbsp;varchar(50)) <br />　　as <br />　　begin <br />　　declare&nbsp;@sql&nbsp;varchar(50) <br />　　set&nbsp;@sql='' <br />　　select&nbsp;@sql=@sql+ltrim(rtrim(tableid))&nbsp;from&nbsp;t <br />　　insert&nbsp;@t&nbsp;values&nbsp;(@sql) <br />　　return <br />　　end <br />　　go <br />　　select&nbsp;*&nbsp;from&nbsp;t <br />　　select&nbsp;*&nbsp;from&nbsp;dbo.f_he() <br />　　drop&nbsp;function&nbsp;f_he <br />　　drop&nbsp;table&nbsp;t <br />　　col <br />　　-------------------------------------------------- <br />　　T1T2T3T4T5T6 <br />　　(所影响的行数为&nbsp;1&nbsp;行)</td>
        </tr>
    </tbody>
</table>
</div>
</div>]]></summary>
	  <link rel="alternate" type="text/html" href="http://www.accdb.net/default.asp?id=1804" /> 
	  <id>http://www.accdb.net/default.asp?id=1804</id> 
  </entry>	
		
  <entry>
	  <title type="html"><![CDATA[NTSVC.OCX控件使用帮助，VB可以用NTSVC.OCX控件将应用程序做成Service服务]]></title>
	  <author>
		 <name>陈格</name>
		 <uri>http://www.accdb.net/</uri>
		 <email>access911@gmail.com</email>
	  </author>
	  <category term="" scheme="http://www.accdb.net/default.asp?cateID=12" label="软件开发" /> 
	  <updated>2012-01-01T18:12:14+08:00</updated>
	  <published>2012-01-01T18:12:14+08:00</published>
		  <summary type="html"><![CDATA[NTSVC.OCX控件使用帮助，VB可以用NTSVC.OCX控件将应用程序做成Service服务2007年02月12日 星期一 上午 10:56使用这个控件注册成Service服务的时候有个需要注意的，如果我们不使用/i或者/u参数，那么建立的Service服务会因为超时而不能启动。所以在注册Service服务的时候，必须带/i或/u参数。<br/><br/>1. 引用控件<br/>选择“工程”－“引用”－“Microsoft NT Service Control”，如果没有，请先将NTSVC.OCX拷贝到%System32%/下，然后再引用对话框中选择浏览，添加该控件。<br/><br/>2. 主要代码<br/>Private Sub Form_Load()<br/>&nbsp;&nbsp;&nbsp;&nbsp;On Error GoTo ServiceError<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#39;安装Service服务<br/>&nbsp;&nbsp;&nbsp;&nbsp;If Command = &#34;/i&#34; Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NTService.Interactive = True<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If NTService.Install Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NTService.SaveSetting &#34;Parameters&#34;, &#34;TimerInterval&#34;, &#34;300&#34;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MsgBox NTService.DisplayName &amp; &#34;: installed successfully&#34;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Else<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MsgBox NTService.DisplayName &amp; &#34;: failed to install&#34;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End<br/>&nbsp;&nbsp;&nbsp;&nbsp;&#39;删除Service服务<br/>&nbsp;&nbsp;&nbsp;&nbsp;ElseIf Command = &#34;/u&#34; Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If NTService.Uninstall Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MsgBox NTService.DisplayName &amp; &#34;: uninstalled successfully&#34;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Else<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;MsgBox NTService.DisplayName &amp; &#34;: failed to uninstall&#34;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End<br/>&nbsp;&nbsp;&nbsp;&nbsp;End If<br/>&nbsp;&nbsp;&nbsp;&nbsp;Timer.Interval = CInt(NTService.GetSetting(&#34;Parameters&#34;, &#34;TimerInterval&#34;, &#34;300&#34;))<br/>&nbsp;&nbsp;&nbsp;&nbsp;NTService.ControlsAccepted = svcCtrlPauseContinue<br/>&nbsp;&nbsp;&nbsp;&nbsp;NTService.StartService<br/>&nbsp;&nbsp;&nbsp;&nbsp;Exit Sub<br/>ServiceError:<br/>&nbsp;&nbsp;&nbsp;&nbsp;Call NTService.LogEvent(svcMessageError, svcEventError, &#34;[&#34; &amp; Err.Number &amp; &#34;] &#34; &amp; Err.Description)<br/>End Sub<br/><br/>&#39;Unload the Service<br/>Private Sub Form_Unload(Cancel As Integer)<br/>&nbsp;&nbsp;&nbsp;&nbsp;If Not StopService Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;If MsgBox(&#34;Are you sure you want to unload the service?...&#34; &amp; vbCrLf &amp; &#34;the service will be stopped&#34;, vbQuestion + vbYesNo, &#34;Stop Service&#34;) = vbYes Then<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;NTService.StopService<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Label1.Caption = &#34;Stopping&#34;<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cancel = True<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Else<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Cancel = True<br/>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;End If<br/>&nbsp;&nbsp;&nbsp;&nbsp;End If<br/>End Sub<br/><br/>Private Sub NTService_Continue(Success As Boolean)<br/>&nbsp;&nbsp;&nbsp;&nbsp;On Error GoTo ServiceError<br/>&nbsp;&nbsp;&nbsp;&nbsp;Timer.Enabled = True<br/>&nbsp;&nbsp;&nbsp;&nbsp;Success = True<br/>&nbsp;&nbsp;&nbsp;&nbsp;NTService.LogEvent svcEventInformation, svcMessageInfo, &#34;Service continued&#34;<br/>&nbsp;&nbsp;&nbsp;&nbsp;Exit Sub<br/>ServiceError:<br/>&nbsp;&nbsp;&nbsp;&nbsp;NTService.LogEvent svcMessageError, svcEventError, &#34;[&#34; &amp; Err.Number &amp; &#34;] &#34; &amp; Err.Description<br/>End Sub<br/><br/>Private Sub NTService_Control(ByVal mEvent As Long)<br/>&nbsp;&nbsp;&nbsp;&nbsp;On Error GoTo ServiceError<br/>&nbsp;&nbsp;&nbsp;&nbsp;Exit Sub<br/>ServiceError:<br/>&nbsp;&nbsp;&nbsp;&nbsp;NTService.LogEvent svcMessageError, svcEventError, &#34;[&#34; &amp; Err.Number &amp; &#34;] &#34; &amp; Err.Description<br/>End Sub<br/><br/>Private Sub NTService_Pause(Success As Boolean)<br/>&nbsp;&nbsp;&nbsp;&nbsp;On Error GoTo ServiceError<br/>&nbsp;&nbsp;&nbsp;&nbsp;Timer.Enabled = False<br/>&nbsp;&nbsp;&nbsp;&nbsp;NTService.LogEvent svcEventError, svcMessageError, &#34;Service paused&#34;<br/>&nbsp;&nbsp;&nbsp;&nbsp;Success = True<br/>&nbsp;&nbsp;&nbsp;&nbsp;Exit Sub<br/>ServiceError:<br/>&nbsp;&nbsp;&nbsp;&nbsp;NTService.LogEvent svcMessageError, svcEventError, &#34;[&#34; &amp; Err.Number &amp; &#34;] &#34; &amp; Err.Description<br/>End Sub<br/><br/>Private Sub NTService_Start(Success As Boolean)<br/>&nbsp;&nbsp;&nbsp;&nbsp;On Error GoTo ServiceError<br/>&nbsp;&nbsp;&nbsp;&nbsp;Success = True<br/>&nbsp;&nbsp;&nbsp;&nbsp;Exit Sub<br/>ServiceError:<br/>&nbsp;&nbsp;&nbsp;&nbsp;NTService.LogEvent svcMessageError, svcEventError, &#34;[&#34; &amp; Err.Number &amp; &#34;] &#34; &amp; Err.Description<br/>End Sub<br/><br/>Private Sub NTService_Stop()<br/>&nbsp;&nbsp;&nbsp;&nbsp;On Error GoTo ServiceError<br/>&nbsp;&nbsp;&nbsp;&nbsp;StopService = True<br/>&nbsp;&nbsp;&nbsp;&nbsp;Unload Me<br/>ServiceError:<br/>&nbsp;&nbsp;&nbsp;&nbsp;NTService.LogEvent svcMessageError, svcEventError, &#34;[&#34; &amp; Err.Number &amp; &#34;] &#34; &amp; Err.Description<br/>End Sub<br/><br/>3. 如果是有其他的控件触发Service服务的Install和Uninstall,可以采用Shell或者WinExec来处理。<br/>先声明函数<br/>Public Declare Function WinExec Lib &#34;kernel32&#34; (ByVal lpCmdLine As String, ByVal nCmdShow As Long) As Long<br/>Public Const SW_HIDE = 0<br/>使用，比如用CheckBox触发<br/>a.安装<br/>&nbsp;&nbsp;&nbsp;&nbsp;Call WinExec(App.EXEName &amp; &#34; /i&#34;, SW_HIDE)<br/><br/>b.卸载<br/>&nbsp;&nbsp;&nbsp;&nbsp;Call WinExec(App.EXEName &amp; &#34; /u&#34;, SW_HIDE)<br/> <br/><br/>]]></summary>
	  <link rel="alternate" type="text/html" href="http://www.accdb.net/default.asp?id=1803" /> 
	  <id>http://www.accdb.net/default.asp?id=1803</id> 
  </entry>	
		
  <entry>
	  <title type="html"><![CDATA[erp往来调整]]></title>
	  <author>
		 <name>陈格</name>
		 <uri>http://www.accdb.net/</uri>
		 <email>access911@gmail.com</email>
	  </author>
	  <category term="" scheme="http://www.accdb.net/default.asp?cateID=12" label="软件开发" /> 
	  <updated>2011-12-28T10:31:46+08:00</updated>
	  <published>2011-12-28T10:31:46+08:00</published>
		  <summary type="html"><![CDATA[<img src="http://www.accdb.net/images/download.gif" alt="下载文件" style="margin:0px 2px -4px 0px"/> <a href="http://www.accdb.net/attachments/month_1112/720111228103133.rar" target="_blank">点击下载此文件</a><br/>]]></summary>
	  <link rel="alternate" type="text/html" href="http://www.accdb.net/default.asp?id=1802" /> 
	  <id>http://www.accdb.net/default.asp?id=1802</id> 
  </entry>	
		
  <entry>
	  <title type="html"><![CDATA[关于Excel的外部引用是否能全部被列出]]></title>
	  <author>
		 <name>陈格</name>
		 <uri>http://www.accdb.net/</uri>
		 <email>access911@gmail.com</email>
	  </author>
	  <category term="" scheme="http://www.accdb.net/default.asp?cateID=5" label="软件类其他" /> 
	  <updated>2011-12-17T18:18:38+08:00</updated>
	  <published>2011-12-17T18:18:38+08:00</published>
		  <summary type="html"><![CDATA[关于Excel的外部引用是否能全部被列出<br/>微软的说法是不可以。<br/><a href="http://office.microsoft.com/zh-cn/excel-help/HP010205611.aspx" target="_blank">http://office.microsoft.com/zh-cn/excel-help/HP010205611.aspx</a><br/><img src="http://www.accdb.net/images/download.gif" alt="下载文件" style="margin:0px 2px -4px 0px"/> <a href="http://www.accdb.net/attachments/month_1112/q20111217181831.mht" target="_blank">点击下载此文件</a><br/>]]></summary>
	  <link rel="alternate" type="text/html" href="http://www.accdb.net/default.asp?id=1800" /> 
	  <id>http://www.accdb.net/default.asp?id=1800</id> 
  </entry>	
		
  <entry>
	  <title type="html"><![CDATA[Excel用Api做定时器]]></title>
	  <author>
		 <name>陈格</name>
		 <uri>http://www.accdb.net/</uri>
		 <email>access911@gmail.com</email>
	  </author>
	  <category term="" scheme="http://www.accdb.net/default.asp?cateID=12" label="软件开发" /> 
	  <updated>2011-12-17T16:21:25+08:00</updated>
	  <published>2011-12-17T16:21:25+08:00</published>
		  <summary type="html"><![CDATA[用Api做定时器<br/><img src="http://www.accdb.net/images/download.gif" alt="下载文件" style="margin:0px 2px -4px 0px"/> <a href="http://www.accdb.net/attachments/month_1112/420111217162057.rar" target="_blank">点击下载此文件</a><br/>]]></summary>
	  <link rel="alternate" type="text/html" href="http://www.accdb.net/default.asp?id=1799" /> 
	  <id>http://www.accdb.net/default.asp?id=1799</id> 
  </entry>	
		
  <entry>
	  <title type="html"><![CDATA[关于新报表系统设计问题]]></title>
	  <author>
		 <name>陈格</name>
		 <uri>http://www.accdb.net/</uri>
		 <email>access911@gmail.com</email>
	  </author>
	  <category term="" scheme="http://www.accdb.net/default.asp?cateID=4" label="财务ERP、企业管理" /> 
	  <updated>2011-12-16T16:43:20+08:00</updated>
	  <published>2011-12-16T16:43:20+08:00</published>
		  <summary type="html"><![CDATA[关于新报表系统设计问题<br/><br/>1、建立公式汇总表。任何被更改的公式都要被记录下来。<br/><br/>难点：<br/>如果公式有外部引用，那么对应的外部工作簿文件名变更该怎么办？<br/>外部工作簿文件名、sheet名同时变更该怎么办？<br/>外部工作簿文件名不变sheet名变怎么办？<br/>插入单元格导致公式中的相对引用变怎么办？<br/>--------- 针对上面所有的问题，干脆就不要考虑工作簿变动问题了，只要变动了，就断开连接，让用户重新确认公式？<br/><br/><br/>公式引用的当前工作簿中的sheet名变更怎么办？-------另外建立一个表格，把公式在表格中再写一遍，sheet名变，这个公式会自动变，判断公式是否变更，也到这个表里面去比对一下。<br/><br/><br/><br/>]]></summary>
	  <link rel="alternate" type="text/html" href="http://www.accdb.net/default.asp?id=1798" /> 
	  <id>http://www.accdb.net/default.asp?id=1798</id> 
  </entry>	
		
  <entry>
	  <title type="html"><![CDATA[excel 外部引用问题]]></title>
	  <author>
		 <name>陈格</name>
		 <uri>http://www.accdb.net/</uri>
		 <email>access911@gmail.com</email>
	  </author>
	  <category term="" scheme="http://www.accdb.net/default.asp?cateID=12" label="软件开发" /> 
	  <updated>2011-12-16T01:38:39+08:00</updated>
	  <published>2011-12-16T01:38:39+08:00</published>
		  <summary type="html"><![CDATA[<a href="http://office.microsoft.com/zh-cn/excel-help/HP010205611.aspx" target="_blank">http://office.microsoft.com/zh-cn/excel-help/HP010205611.aspx</a><br/><br/>&nbsp;&nbsp; <br/>&nbsp;&nbsp;查找工作簿中的外部引用（链接）<br/>适用于: Microsoft Office Excel 2007<br/><br/>打印 全部显示全部隐藏<br/>在查找目标 （目标文件:链接或嵌入对象所插入的文件。源文件包括用来创建对象的信息。当更改目标文件中的信息后，不更新源文件中的信息。）工作簿中使用的外部引用（又称为链接）时，不存在自动的方式。但是，在关闭工作簿时，外部引用会使用方括号 [ ] 将源 （源文件:该文件中包含创建链接对象或嵌入对象所用的信息。更新源文件中的信息时，还可以同时更新目标文件中的链接对象。）工作簿的名称括起，例如 =SUM([Budget.xls]Annual!C10:C25)，因此可以使用这些字符来定位外部引用。<br/><br/>要查找目标工作簿中的所有外部引用，需要在单元格、名称、对象（例如文本框或形状）、图表标题和图表数据系列中进行查找。<br/><br/>您要做什么？<br/><br/>--------------------------------------------------------------------------------<br/><br/>查找单元格中使用的外部引用<br/>查找名称中使用的外部引用<br/>查找文本框或形状等对象中使用的外部引用<br/>查找图表标题中使用的外部引用<br/>查找图表数据系列中使用的外部引用<br/><br/>--------------------------------------------------------------------------------<br/>查找单元格中使用的外部引用<br/>1.关闭所有源工作簿，然后打开目标工作簿。<br/>2.在“开始”选项卡上的“编辑”组中，单击“查找和选择”，然后单击“查找”。<br/> <br/><br/>将显示“查找和替换”对话框。<br/><br/>3.单击“选项”。<br/>4.在“查找内容”框中，输入 [。<br/>5.在“范围”框中，单击“工作簿”。<br/>6.在“查找范围”框中，单击“公式”。<br/>7.单击“查找全部”。<br/>8.在显示的列表框的“公式”列中，查找包含 [ 的公式。<br/> 提示&nbsp;&nbsp; 单击“公式”列标题，以便对该列进行排序并将所有外部引用分组在一起。<br/><br/>9.要选择包含外部引用的单元格，请在列表框中选择该行。<br/> 返回页首<br/><br/>查找名称中使用的外部引用<br/>1.关闭所有源工作簿，然后打开目标工作簿。<br/>2.在“公式”选项卡上的“定义的名称”组中，单击“名称管理器”。<br/>3.检查列表中的每一项，并在“引用位置”列中查找外部引用。外部引用包含对其他工作簿的引用，例如 [Budget.xls]。<br/> 提示&nbsp;&nbsp; 单击“引用位置”列标题，以便对该列进行排序并将所有外部引用分组在一起。<br/><br/> 返回页首<br/><br/>查找文本框或形状等对象中使用的外部引用<br/>1.关闭所有源工作簿，然后打开目标工作簿。<br/>2.在“开始”选项卡上的“编辑”组中，单击“查找和选择”旁边的箭头，然后单击“定位条件”。<br/> <br/><br/>3.单击“对象”，然后单击“确定”。<br/>4.按 Tab 键，然后在编辑栏 （编辑栏:位于 Excel 窗口顶部的条形区域，用于输入或编辑单元格或图表中的值或公式。编辑栏中显示了存储于活动单元格中的常量值或公式。）&nbsp;&nbsp;中查找对其他工作簿的引用，例如 [Budget.xls]。对象的名称将显示在“名称”框中。<br/>5.对于工作表中的每个对象，请重复步骤 4。<br/>6.对于工作簿中的每个工作表，请重复步骤 2 到步骤 5。<br/> 返回页首<br/><br/>查找图表标题中使用的外部引用<br/>1.关闭所有源工作簿，然后打开目标工作簿。<br/>2.在要检查的图表上单击图表标题。<br/>3.在编辑栏 （编辑栏:位于 Excel 窗口顶部的条形区域，用于输入或编辑单元格或图表中的值或公式。编辑栏中显示了存储于活动单元格中的常量值或公式。）&nbsp;&nbsp;中，查找对其他工作簿的引用，例如 [Budget.xls]。<br/>4.对于工作簿中具有图表标题的每个图表，请重复步骤 2 和步骤 3。<br/> 返回页首<br/><br/>查找图表数据系列中使用的外部引用<br/>1.关闭所有源工作簿，然后打开目标工作簿。<br/>2.选择要检查的图表。<br/>3.在“布局”选项卡上的“当前选择”组中，单击“图表元素”框旁边的箭头，然后单击要检查的数据系列 （数据系列:在图表中绘制的相关数据点，这些数据源自数据表的行或列。图表中的每个数据系列具有唯一的颜色或图案并且在图表的图例中表示。可以在图表中绘制一个或多个数据系列。饼图只有一个数据系列。）。<br/> <br/><br/>4.在编辑栏 （编辑栏:位于 Excel 窗口顶部的条形区域，用于输入或编辑单元格或图表中的值或公式。编辑栏中显示了存储于活动单元格中的常量值或公式。）&nbsp;&nbsp;中，查找对其他工作簿的引用，例如 SERIES 函数中的 [Budget.xls]。<br/>5.对于图表中的每个数据系列，请重复步骤 3。<br/>6.对于工作簿中的每个图表，请重复步骤 2 到步骤 5。<br/> 返回页首<br/><br/>]]></summary>
	  <link rel="alternate" type="text/html" href="http://www.accdb.net/default.asp?id=1797" /> 
	  <id>http://www.accdb.net/default.asp?id=1797</id> 
  </entry>	
		
</feed>
