Dual Where Clause Problems


(system) #1

Hello,

My names Alex, I'm new to Epicor development and come from a strong PHP background. So all this is a little bit different!

I've been having some issues the last few days trying to build up a simple select statement with 2 conditions. I wondered if I was to put some code below would anyone be able to shed some light on the problem?

--------------------------------------------------------------------------------------------------------------------------------------------

 this._ud05Adapter = new UD05Adapter(this.oTrans);

this._ud05Adapter.BOConnect();

// Add Adapter Table to List of Views
// This allows you to bind controls to the custom UD Table
this._edvUD05 = new EpiDataView();
this._edvUD05.dataView = new DataView(this._ud05Adapter.UD05Data.UD05);
this._edvUD05.AddEnabled = true;
this._edvUD05.AddText = "New UD05";

if ((this.oTrans.EpiDataViews.ContainsKey("UD05View") == false))
{
this.oTrans.Add("UD05View", this._edvUD05);
}



System.Collections.Hashtable whereClauses = new System.Collections.Hashtable(1);
string whereClause = "UD05.ShortChar03 = '" + CurrentJobNumber + "'";
whereClauses.Add("UD05", whereClause);


// Call the adapter search.
SearchOptions searchOptions = SearchOptions.CreateRuntimeSearch(whereClauses, DataSetMode.RowsDataSet);

--------------------------------------------------------------------------------------------------------------------------------------------

 The above on it's own seems to work just fine however when applying a second condition to the code...

--------------------------------------------------------------------------------------------------------------------------------------------

System.Collections.Hashtable whereClauses = new System.Collections.Hashtable(1);

string whereClause = "UD05.ShortChar03 = '" + CurrentJobNumber + "' AND UD05.Number01 IN (" + strMtlSeqListing + ")";
whereClauses.Add("UD05", whereClause);

--------------------------------------------------------------------------------------------------------------------------------------------

When running the above code I'm met with a "do not understand after [jobnumber]' AND" error message. When taking the where condition away and running it against the database directly it has no problem. I do however note that the condition I'm adding do not seem to be the only conditions being added. When changing the query in certain ways you can get a glimpse of another condition for the Company field. I think this condition stands to reason but I'm also concerned it's causing my problem, though to me it seems unlikely.

I have tried utilizing the hash table and creating a second record with another where condition however that plan was flawed as the hash table won't allow another record with the same key 'UD05'. A problem as this seems to be the field used in the hash table by CreateRunTimeSearch to look up the where conditions, depsite passing the hash table whereClauses into it the second condition is always missed or looked over.

It is my belief that the above code that does not seem to work is the intended way of operating but theres something wrong and I can't see it!
Does anyone have any ideas?