<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Code</title><link>https://www.infopathdev.com:443/forums/45.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: Accessing Code for Submission</title><link>https://www.infopathdev.com:443/forums/thread/13249.aspx</link><pubDate>Thu, 09 Jun 2005 17:55:44 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:13249</guid><dc:creator>jimmyfo</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/13249.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=13249</wfw:commentRss><description>Hi, the code I'm testing the query with to see if the name exists is as follows:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;// Get the default SQL command for the form.&lt;br /&gt;  var strOrigSQLCommand = XDocument.QueryAdapter.Command;&lt;br /&gt;&lt;br /&gt;  // Get the query node that you want to check.&lt;br /&gt;  //var queryName = XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/@name");&lt;br /&gt;&lt;br /&gt;  //Set the value of the datafield.&lt;br /&gt;  var queryName = XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/d:applicantTable/@name");&lt;br /&gt;&lt;br /&gt;  // Construct the full query string.&lt;br /&gt;  var strSQLQuery = strOrigSQLCommand;&lt;br /&gt;  strSQLQuery = "select name '" + queryName.text + "' from applicantTable";&lt;br /&gt;  &lt;br /&gt;  // This is the query.&lt;br /&gt;  XDocument.UI.Alert(strSQLQuery);&lt;br /&gt;&lt;br /&gt;  // Run the query.&lt;br /&gt;  XDocument.QueryAdapter.Command = strSQLQuery;&lt;br /&gt;  try&lt;br /&gt;  {&lt;br /&gt;	XDocument.Query();&lt;br /&gt;	XDocument.UI.Alert("No Value for name in database.");&lt;br /&gt;  }&lt;br /&gt;  catch(ex)&lt;br /&gt;  {&lt;br /&gt;	XDocument.UI.Alert("Name in database or invalid return." + ex.number + " " + ex.description);&lt;br /&gt;  }&lt;br /&gt;&lt;br /&gt;  // Restore the default table command (for the next time).&lt;br /&gt;  XDocument.QueryAdapter.Command = strOrigSQLCommand;&lt;br /&gt;}&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;The error message I get on runtime is:&lt;br /&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;The following error occurred:&lt;br /&gt;&lt;br /&gt;The query method on the Document object failed.&lt;br /&gt;InfoPath cannot run the specified query.&lt;br /&gt;The XML data returned from the data source does not match the XML Schema for this form. This discrepancy might be caused by the data source returning multiple rows when InfoPath expects only one.&lt;br /&gt;Attribute 'James_Fogarty' is not allowed on element '&lt;a target="_blank" href=http://schemas.microsoft.com/office/infopath/2003/ado/dataFields}applicantTable'&gt;http://schemas.microsoft.com/office/infopath/2003/ado/dataFields}applicantTable'&lt;/a&gt;, according to Schema.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;File:script.js&lt;br /&gt;Line:150&lt;br /&gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Any ideas?&lt;br /&gt;&lt;br /&gt;Thanks.&lt;br /&gt;&lt;br /&gt;James</description></item><item><title>Accessing Code for Submission</title><link>https://www.infopathdev.com:443/forums/thread/12462.aspx</link><pubDate>Wed, 08 Jun 2005 16:27:54 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:12462</guid><dc:creator>jimmyfo</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/12462.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=12462</wfw:commentRss><description>Hi, I'm using rules for the submit to both drop the information to the database and publish to the SharePoint portal. I'm using a function to make the name of the file a concatanation of a static word and the primary key variable. My question is: if I am trying to submit the same value as one that already exists in the database as a primary key, I would like to append the next available number (starting at 1) to the end of the name. How would I do that, and if I were, where would I access and change the code that InfoPath is using to do the two submissions?&lt;br /&gt;&lt;br /&gt;Example:&lt;br /&gt;John Doe - existing primary key in database.&lt;br /&gt;-&amp;gt;trying to submit new John Doe (same name, different person)&lt;br /&gt;John Doe, John Doe1 - primary keys in database.&lt;br /&gt;&lt;br /&gt;Likewise, is it possible to delete simultaneously from the Portal and the Database?&lt;br /&gt;&lt;br /&gt;Thanks and regards,&lt;br /&gt;James&lt;br /&gt;&lt;br /&gt;EDIT: I am using custom code for the submit to the database and the portal - the problem now lies with checking if the name already exists in them (since they reflect each other exactly) and if they do, appending a number onto the end. How can I check the database and change the submission values instead of using XDocument.Submit()? The same with the portal drop. Thanks again - this would be a huge help.</description></item></channel></rss>