File: xdmthBuildSQLFromXMLNodes.htm

package info (click to toggle)
office2003-schemas 1.0%2Bds-1
  • links: PTS, VCS
  • area: non-free
  • in suites: bookworm, forky, sid, trixie
  • size: 42,304 kB
  • sloc: javascript: 2,429; makefile: 29
file content (79 lines) | stat: -rw-r--r-- 5,163 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<html dir="ltr"><head>
<META http-equiv="Content-Type" content="text/html; charset=UTF-8">
<META HTTP-EQUIV="assetid" CONTENT="HV01021378"><META NAME="lcid" CONTENT="1033"><title>BuildSQLFromXMLNodes Method</title><link rel="stylesheet" type="text/css" href="office10.css"><script type="text/javascript" language="Javascript" src="ExpCollapse.js"></script><script type="text/javascript" language="JavaScript" src="inline.js"></script></head><body><h1>BuildSQLFromXMLNodes Method</h1><DIV class="ofvbanav"><span class="ofvbanavreuse" id="seealso" onclick="toggleList()" onkeypress="toggleList()"></span><span class="ofvbanavreuse" id="appliesto" onclick="toggleList()" onkeypress="toggleList()"></span><a class="ofvbanavex" href="#example"><span class="ofvbanavreuse" id="example"></span></a><span class="ofvbanavreuse" id="specifics" onclick="toggleList()" onkeypress="toggleList()"></span></DIV><p>
      <p>Returns a string containing an SQL command text fragment using the specified XML node.</p>
      
        <p class="signature"><i>expression</i>.<b class="bterm">BuildSQLFromXMLNodes</b>(ByRef <b class="bterm"><i>pXmlNode</i></b> As IXMLDOMNode) As String</p>
        <p><i>expression   </i> Required. An expression that returns a reference to the <b class="bterm"><a href="xdobjADOAdapter.htm" id="HV01021238" lcid=" ">ADOAdapter</a></b> object.</p><p>
          <b class="bterm">
            <i>pXmlNode</i>
          </b>Required <b class="bterm">Object</b>. The XML node to be converted to an SQL fragment.</p>
      <p><i>returns   </i> <b class="bterm">String</b>.</p>  
    </p><h2>Security Level</h2><p>2: Can be accessed only by forms running in the same domain as the currently open form, or by forms that have been granted cross-domain permissions.</p><h2>Remarks</h2><p>
      <p>The fragment of SQL that the <b class="bterm">BuildSQLFromXMLNodes</b> method generates is an SQL <code>WHERE</code> clause in the form of <code>field = value</code>. The XML node that you use for the <b class="bterm"><i>pXmlNode</i></b> argument should be a descendant  of the dfs:queryFields node; when you have the SQL command text fragment, you can add it to the existing SQL command string of the <b class="bterm">ADOAdapter</b> object using the <b class="bterm"><a href="xdproCommand.htm" id="HV01021267" lcid=" ">Command</a></b> property.</p>
    </p><h2><a id="#example" name="#example">Example</a></h2><p>
      <p>In the following example, the <b class="bterm">BuildSQLFromXMLNodes</b> method of the <b class="bterm">ADOAdapter</b> object is used to create an SQL command text fragment based on a specified XML node. This example is based on a form that uses the Orders table in the Microsoft SQL Server Northwind sample database.</p>
      <pre><code>function QueryGreaterThan()
{
   var objQueryFieldNode;
   var strWhereClause;
   var strOldCommand;
   var objQueryFieldAttributes;
   var objCurQueryFieldAttribute;

   // Build the WHERE clause from the QueryFields in the form's
   // underlying XML DOM.
   objQueryFieldNode = XDocument.DOM
      .selectSingleNode("dfs:myFields/dfs:queryFields/q:Orders");
   strWhereClause = XDocument.QueryAdapter
      .<b class="bterm">BuildSQLFromXMLNodes</b>(objQueryFieldNode);

   // Replace the '=' signs with '&gt;=', and append the clause to 
   // the SQL command text.
   strWhereClause = strWhereClause.replace(/=/, "&gt;=");
   strOldCommand = XDocument.QueryAdapter.Command;
	
   if (strWhereClause != "")
   {
      XDocument.QueryAdapter.Command = strOldCommand + 
         " where " + strWhereClause;
   }
	
   // Clear the QueryFields so the WHERE clause isn't 
   // automatically generated.
   objQueryFieldAttributes = objQueryFieldNode.attributes;
   while (objCurQueryFieldAttribute = objQueryFieldAttributes.nextNode())
   {
      objCurQueryFieldAttribute.text = "";
   }
	
   // Perform the query.
   try
   {
      XDocument.Query();
   }
   catch (e)
   {
      XDocument.UI.Alert("Failed to query.\n\n" + e.message);
   }
	
   // Reset the command so that subsequent queries are based on 
   // the correct SQL command text string.
   XDocument.QueryAdapter.Command = strOldCommand;

   // Clean up.
   objQueryFieldNode = null;
   strWhereClause = null;
   strOldCommand = null;
   objQueryFieldAttributes = null;
   objCurQueryFieldAttribute = null;

}
</code></pre>
    </p><script type="text/javascript" language="JScript" src="ofvbanl.js"></script><span id="ofVBAISpan" class="ofvbaispan"><iframe id="ofVBAIFrame" frameborder="0" marginheight="0" marginwidth="4" scrolling="auto" width="100%" src="../links/xdmthBuildSQLFromXMLNodes_l.htm"></iframe></span><center><a href="XMLSchemaCopyright_HV01147162.htm">&copy;2003-2004 Microsoft Corporation. All rights reserved.</a>  

Permission to copy, display and distribute this document is available at: <a 

href="http://r.office.microsoft.com/r/rlidAWSContentRedir?AssetID=XT010988631033&amp;CTT=11&amp;Origin=HV011232471033" 

target="_new">http://msdn.microsoft.com/library/en-us/odcXMLRef/html/odcXMLRefLegalNotice.asp</a></center></body></html>