Strange UltraGrid behaviour

I am running a BAQ in code and dumping the results into an UltraGrid. Everything works great as usual except when I noticed that if my BAQ resulted in no records, the grid remains unchanged with the old data.

A simply solution I found was to set the UltraGrid.DataSource = null before running the BAQ and populating results. The problem is that after the first successful query, I run another query and the results do no display properly (I can verify that I have records in the results). The grid gets a strange arrow, see picture:

You should make an EpiDataView for the BAQ Results then use DataSet merge for the results and DataTable clear so that you don’t loose the formatting.

I’ve used pre-existing dataviews but I’ve never spawned my own. Any guidelines or warnings? (Or free samples) :kissing_cat:

1 Like

DataTable dt = new DataTable();

EpiDataView edv = new EpiDataView();
edv.dataView = dt.defaultView;

oTrans.Add("MyAewsomeView, edv);

now you have a working EpiDataView and any data added to the dt data table… will do its thing… You can bind grids to it , fire notifications … the works

Now you can expand that by instead of using a standard DataTable you can execute your query and get back the DataSet.Tables[“Results”] and make said Results table your DataTable for the EpiDataView… then use dataSet.Merge() to update or add to the table… etc…
Sorry I am slammed today so I can’t give you a spoon fed example, but this should get you close

1 Like

One of these days I am going to have to get some schooling on oTrans, DataViews, and the likes (maybe I will learn this in Customization classes at Insights2017)

By changing MyGrid.DataSource = dqa.QueryResults to
MyGrid.DataSource = dqa.QueryResults.Tables[“Results”]; seems to have made the issue go away.

        epiUltraGridXfers.DataSource = null;
	DynamicQueryAdapter dqa = new DynamicQueryAdapter(oTrans);
	dqa.BOConnect();
	QueryExecutionDataSet qeds = dqa.GetQueryExecutionParametersByID("inv_move_by_part_cc");
	qeds.ExecutionParameter.Clear();
	string pn = "%";
	string emp = ((Ice.Core.Session)(oTrans.Session)).EmployeeID;
	
	qeds.ExecutionParameter.AddExecutionParameterRow("PartNum",pn,"nvarchar",false,Guid.NewGuid(),"A");
	qeds.ExecutionParameter.AddExecutionParameterRow("Emp",emp,"nvarchar",false,Guid.NewGuid(),"A");
	dqa.ExecuteByID("inv_move_by_part_cc",qeds);
		if(dqa.QueryResults.Tables["Results"].Rows.Count > 0)
		{
				epiUltraGridXfers.DataSource = dqa.QueryResults.Tables["Results"];
		}
	}

Sorry to highjack this thread but would anyone be able to share an example of how to use dataset.Merge() to update an EpiDataView as mentioned earlier in post?

Thanks,
Tanner