Search Error  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

Search Error

Postby SBarnes » Fri Dec 08, 2017 2:34 pm

The following code is showing an error about argument length must be greater than or equal to zero when the search dialog appears and I can not work out why.

Code: Select all
public void Search(System.Windows.Forms.Form OwnerForm)
        {

         var search = this.Manager.Search;
         

            search.Clear();
            search.Caption = "Salesman Groups";

            var searchOption = new JiwaFinancials.Jiwa.JiwaApplication.JiwaSearch.SearchOption();
            searchOption.Title = "Salesman Groups";
         

            searchOption.SQLStr = @" SELECT SalesmanGroupID as ID
                              ,Description
                             FROM HR_SalesmanGroups where Description <> '' ";
            searchOption.OrderBy = @" order by Description ";
      
            searchOption.AddColumn("ID", Microsoft.VisualBasic.VariantType.String, "", 0, 1);
         searchOption.AddColumn("Description", Microsoft.VisualBasic.VariantType.String, "", 100, 2);
           // search.Options.Clear();
            search.AddSearchOption(ref searchOption);

            if (search.Show(OwnerForm) == DialogResult.OK)
            {
                if (search.Results.Count > 0)
                {
                    var idField = (JiwaFinancials.Jiwa.JiwaApplication.JiwaSearch.Field)search.get_Fields(1);
                    Read(idField.FieldValue.ToString());
                }
            }
            else
            {
                throw new JiwaFinancials.Jiwa.JiwaApplication.Exceptions.ClientCancelledException();
            }
        }
      
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Search Error  Topic is solved

Postby SBarnes » Sat Dec 09, 2017 7:55 am

I have changed this code to use a view rather than a straight SQL statement, in the view the field "Description" is now being called "GroupName", I suspect this is the actual problem that somewhere along the way it is the use of the word Description as a field name that is the issue, I don't see why, but unfortunately its a table in a system that already has data in it so it can't be changed so I guess the view is the best answer.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1619
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 27 guests