whereClause Error

I used the Wizard to create a simple search on the Sales Order. There is a Quick Search attached to it. When I run the search I get the following error.

//Order - Method for Sales Order Search in Orders Section
	private void SearchOnSalesOrderAdapterShowDialog() 
	{
		 //Wizard Generated Search Method
		 //You will need to call this method from another method in custom code
		 //For example, [Form]_Load or [Button]_Click
		bool recSelected;
		string whereClause = string.Empty;
		System.Data.DataSet dsSalesOrderAdapter = Ice.UI.FormFunctions.SearchFunctions.listLookup(this.oTrans, "SalesOrderAdapter", out recSelected, true, whereClause);
		if (recSelected)
		{
			System.Data.DataRow adapterRow = dsSalesOrderAdapter.Tables[0].Rows[0];
			 //Map Search Fields to Application Fields
			numOrderDtl_OrderNum.Value = adapterRow["OrderNum"];
			epiNumericOrderNumRef.Value = adapterRow["OrderNum"];
			epiTextBoxPORefNum.Text = adapterRow["PONum"].ToString();
			changeordernumber();
		}
	}

Try making the where clause string be something that returns everything. Like

"Company LIKE '%' "

If you are in a multi-company environment try this. This should get your current company so that you are loading data you have access to.

Ice.Core.Session ses = (Ice.Core.Session);
string sescomp = ses.Company;
string WhereClause = sescomp;

That all looks like the standard boilerplate for an order search except for setting a couple of fields and a call to the changeordernumber() method which should all be fine. I even ran a diff check against one that I have in a working form and it all matched.

Going back to the actual error message, are you 100% sure that the error is coming from this section of code? The whereClause in the code you posted is empty and there’s no additional assignment before the adapter lookup. Also, where is the value of ROCKCHALK coming from? Is that a value from a different field on the order you selected? If so, are you assigning that field to something else like an adapter lookup?

You should share the quick search. It seems there is an issue. Isnt OrderNum an int? If so you cant compare it to a string, but in your error, it shows ROCKCHALK, but it is not surrounded by quotes, strange.

I figured out what it was. The Quick Search Settings got changed and instead of Ordernum returning it was returning PONum.

1 Like