Actually, if your form's main DOM is the database connection, you can issue queries against it through the "queryFields" group.
However, when trying to make a secondary data connection to a DB you can't accomplish this in the IP designer, but you can through the use of code. Just add a regular database connection, and then write a little code that does something like this:
// Grab the field from the form
string sCurrentId = getNodeValue("/my:Timecard/my:Common/my:ResourceId");
// Construct the query
ADOAdapter dbConn = (ADOAdapter)thisXDocument.DataObjects["Project-WorkItems"].QueryAdapter;
dbConn.Command = ConstructResourceQueryString(sCurrentId);
thisXDocument.DataObjects["Project-WorkItems"].Query();
private string ConstructResourceQueryString(string sResourceId)
{
sResourceId = ConvertIPGuid(sResourceId);
string[] lines = new string[11];
lines[0] = "shape ";
lines[1] = "{select \"ProjectID\",\"Name\",\"Code\",\"StartDate\",\"CustomerID\",\"RateOverhead\",\"Billable\" from \"dbo\".\"Project\" as \"Project\"} as \"Project\"";
lines[2] = "append";
lines[3] = "({select \"WorkItemID\",\"Description\",\"Hours\",\"Rate\",\"ResourceID\",\"Completed\",\"MilestoneID\",\"ProjectID\",\"StartDate\" from \"dbo\".\"WorkItem1\" as \"WorkItem1\" }";
lines[4] = "relate \"ProjectID\" TO \"ProjectID\") as \"WorkItem1\", ";
lines[5] = "({select \"WorkItemID\",\"Description\",\"Hours\",\"Rate\",\"ResourceID\",\"Completed\",\"MilestoneID\",\"ProjectID\",\"StartDate\" from \"dbo\".\"WorkItem2\" as \"WorkItem2\" where \"ResourceID\" = '" + sResourceId + "'}";
lines[6] = "relate \"ProjectID\" TO \"ProjectID\") as \"WorkItem2\", ";
lines[7] = "({select \"WorkItemID\",\"Description\",\"Hours\",\"Rate\",\"ResourceID\",\"Completed\",\"MilestoneID\",\"ProjectID\" from \"dbo\".\"WorkItem3\" as \"WorkItem3\" where \"ResourceID\" = '" + sResourceId + "'}";
lines[8] = "relate \"ProjectID\" TO \"ProjectID\") as \"WorkItem3\", ";
lines[9] = "({select \"WorkItemID\",\"Description\",\"Hours\",\"Rate\",\"ResourceID\",\"Completed\",\"MilestoneID\",\"ProjectID\" from \"dbo\".\"WorkItem4\" as \"WorkItem4\" where \"ResourceID\" = '" + sResourceId + "'}";
lines[10] = "relate \"ProjectID\" TO \"ProjectID\") as \"WorkItem4\"";
string query = String.Format("{0} {1} {2} {3} {4} {5} {6} {7} {8} {9} {10} ",
lines[0],
lines[1],
lines[2],
lines[3],
lines[4],
lines[5],
lines[6],
lines[7],
lines[8],
lines[9],
lines[10]);
return query;
}
This example uses C#.NET, but should be able to convert to any other language that IP supports. I hope this helps!
Matt Faus / Microsoft InfoPath MVPQdabra® Software / Streamline data gathering to turn process into knowledge