Passing a parameter to a BAQ

Hiii,
I’ve been trying to filter out my updatable BAQ by passing in a parameter. Within the returned values, I can then make certain modifications as necessary. This is my code right now…

private void testButton_Click(object sender, System.EventArgs args)
	{
		// ** To Test making changes to a BAQ **
		dynamicQueryAdapter = new DynamicQueryAdapter(oTrans);
		dynamicQueryAdapter.BOConnect();

		var dqds = dynamicQueryAdapter.GetQueryExecutionParametersByID("test_minh5");
		dqds.ExecutionParameter[0].ParameterID = "jobTitle";
		dqds.ExecutionParameter[0].ParameterValue = "test";
		dqds.AcceptChanges();

		bool more;
		var ds = dynamicQueryAdapter.GetList("test_minh5", dqds, 0, 0, out more);
		DataRow row = ds.Tables[0].Rows[0];
		MessageBox.Show("ds.Tables[0].Rows.Count " + ds.Tables[0].Rows.Count );
		row["UD15_Character06"] = "pls work";
		row["RowMod"] = "U";
		dynamicQueryAdapter.Update("test_minh5", ds);
	} 

The code works fine with no errors, but the filter is not working, as in, I still get my entire table returned.
As for how I set up my BAQ …
this is the SQL used to fetch it…
image
and this is the table criteria (when I manually do it, a form appears which allows me to enter the ‘jobTitle’ param → this works fine and returns me the rows I expect).

I am confused as to why my code is not working. Thanks for all the help!

I am not sure why your specific example is not working. I often use parameters in my custom code to filter my BAQs. In this example, I am filtering a BAQ that feeds a combo box.

	private void getRevs()
	{
		oTrans.PushStatusText("Looking for part revisions...", false);
		cmbpartrev = (Ice.Lib.Framework.BAQCombo)csm.GetNativeControlReference("67f0a748-4944-468b-96b0-cce76dfb5588");
		DynamicQueryAdapter dqa = new DynamicQueryAdapter(oTrans);
		dqa.BOConnect();
		QueryExecutionDataSet qeds = dqa.GetQueryExecutionParametersByID("getPartRev");
		qeds.ExecutionParameter.Clear();
		qeds.ExecutionParameter.AddExecutionParameterRow("part", txtPartNum.Text, "nvarchar", false, Guid.NewGuid(), "A");
		dqa.ExecuteByID("getPartRev", qeds);
		if (dqa.QueryResults.Tables["Results"].Rows.Count > 0)
		{
			cmbpartrev.DataSource = dqa.QueryResults.Tables["Results"];
			cmbpartrev.DisplayMember = "PartRev_RevisionNum";
			cmbpartrev.ValueMember = "PartRev_RevisionNum";
		MyResourceID.ForceRefreshList();
		MyRGID.ForceRefreshList();
		}
	oTrans.PushStatusText("Done!", false);
	}

In this example, my BAQ is called “getPartRev”. I have a parameter in the BAQ called ‘part’. The code just populates that parameter based on the value in the previous part field. I use the results of the filtered BAQ to populate the combobox with the revisions for the part number that was previously selected. The main difference I can see is that I am using ExecuteByID.
Sorry I couldn’t be more help. Good luck!

3 Likes

That was actually really helpful…Thank you!

2 Likes