Hi, I’m trying to set some values on some text boxes through a BAQ, using a part number as an execution parameter. This method is called on an EpiViewNotification event too. Here’s the code:
public void getweight()
{
DynamicQueryAdapter dqa = new DynamicQueryAdapter(oTrans);
dqa.BOConnect();
QueryExecutionDataSet qeds = dqa.GetQueryExecutionParametersByID("QuoteWeight");
qeds.ExecutionParameter.Clear();
if (txtPartNumber.Text == "")
{
}
else
{
qeds.ExecutionParameter.AddExecutionParameterRow("PartNum", txtPartNumber.Text, "nvarchar", false, Guid.NewGuid(), "A");
}
dqa.ExecuteByID("QuoteWeight", qeds);
if (( dqa.QueryResults.Tables["Results"].Rows.Count > -1))
{
txtweight.Value = ((decimal)dqa.QueryResults.Tables["Results"].Rows[0][0]);
txttotweight.Value = (((decimal)dqa.QueryResults.Tables["Results"].Rows[0][0]) * Convert.ToInt32(numExpectedQty.Value));
}
}
It gives me an error that no row exists in position 0 unless I omit the lines that grab the values and places them in txtweight and txttotweight… but those shouldn’t even fire if my BAQ returns zero rows in the IF statement that those lines are contained in. Maybe I’m missing something or my code is just wrong. Appreciate any help or advice. Thank you!