Hello, I saw the post "Secondary data source query". This is:
Put the following code in the event handler of a button
---
// Retrieve the SQL statement of the data source
var strSQL = XDocument.DataObjects["YourDataSourceName"].QueryAdapter.Command;
// Retrieve the field in the InfoPath form whose value will be used in the
WHERE clause
var node = XDocument.DOM.selectSingleNode("my:myFields/my:field1");
// Generate the new SQL statement with WHERE clause
strSQL += " where tableFieldName = '" + node.text + "'";
// Populate the command with the new SQL statement
XDocument.DataObjects["YourDataSourceName"].QueryAdapter.Command = strSQL;
// Run the query
XDocument.DataObjects["YourDataSourceName"].Query();
I did this, but don't work. When I put fields of one table this work, but
don't work if I put fields of two tables.
I have fields of table1 and table2. Table1 is the primary table and has a
relationship with table2.
In the line:
var node = XDocument.DOM.selectSingleNode("my:myFields/my:field1");
I write:
var node =
XDocument.DOM.selectSingleNode("dfs:myFields/dfs:queryFields/q:table1");
When I write a value in a field of table1 and press the query button I
obtain an error.
If I write a value only in a field of table2 and press the query button The
result is the SELECT with out WHERE and work fine.
S.Y.M. Wong-A-Ton said:
Did you also see the post in this newsgroup with the title "Secondary data
source query"? It shows how to add a WHERE-clause to the SQL statement of two
related tables in a secondary data source. You should be able to easily
extend it to your own situation.
---
S.Y.M. Wong-A-Ton
:
hello, i have seem many questions about how to do custom queries. Answers
are examples with one table.
I want to do a custom query (add a where to the select with "LIKES", etc)
but I have in the form fields of two different tables. They are includes in
the same database.
How should I do?
Thanks.