Hi, the code I'm testing the query with to see if the name exists is as follows:
// Get the default SQL command for the form.
var strOrigSQLCommand = XDocument.QueryAdapter.Command;
// Get the query node that you want to check.
//var queryName = XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/@name");
//Set the value of the datafield.
var queryName = XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields/d:applicantTable/@name");
// Construct the full query string.
var strSQLQuery = strOrigSQLCommand;
strSQLQuery = "select name '" + queryName.text + "' from applicantTable";
// This is the query.
XDocument.UI.Alert(strSQLQuery);
// Run the query.
XDocument.QueryAdapter.Command = strSQLQuery;
try
{
XDocument.Query();
XDocument.UI.Alert("No Value for name in database.");
}
catch(ex)
{
XDocument.UI.Alert("Name in database or invalid return." + ex.number + " " + ex.description);
}
// Restore the default table command (for the next time).
XDocument.QueryAdapter.Command = strOrigSQLCommand;
}
The error message I get on runtime is:
The following error occurred:
The query method on the Document object failed.
InfoPath cannot run the specified query.
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.
Attribute 'James_Fogarty' is not allowed on element 'http://schemas.microsoft.com/office/infopath/2003/ado/dataFields}applicantTable', according to Schema.
File:script.js
Line:150
Any ideas?
Thanks.
James