D
Dan Holmes
i have a table of products and there is a screen to search for them. I
am stuck as to how to distinguish that the user doesn't want to include
that criteria with that criteria is blank.
Here is a sample:
public List<ProductInfo> List(IVS.Framework.Identity id, ProductInfo
productInfo1, ProductInfo productInfo2)
{
List<ProductInfo> returnData = null;
StringBuilder sql = new StringBuilder();
....snipped stuff
if (!string.IsNullOrEmpty(productInfo1.ProductID))
sql.AppendFormat(" AND ProductID LIKE '{0}%'", productInfo1.ProductID);
if (!string.IsNullOrEmpty(productInfo1.CategoryID))
sql.AppendFormat(" AND CategoryID LIKE '{0}%'",
productInfo1.CategoryID);
else if (productInfo1.CategoryID == null)
sql.Append(" AND CategoryID IS NULL");
in the case of a productid it can never be null but a category could.
How have you guys done this? The above will always look for categoryid
of null even when i only want to search by productid or i have to
include a category too.
dan
am stuck as to how to distinguish that the user doesn't want to include
that criteria with that criteria is blank.
Here is a sample:
public List<ProductInfo> List(IVS.Framework.Identity id, ProductInfo
productInfo1, ProductInfo productInfo2)
{
List<ProductInfo> returnData = null;
StringBuilder sql = new StringBuilder();
....snipped stuff
if (!string.IsNullOrEmpty(productInfo1.ProductID))
sql.AppendFormat(" AND ProductID LIKE '{0}%'", productInfo1.ProductID);
if (!string.IsNullOrEmpty(productInfo1.CategoryID))
sql.AppendFormat(" AND CategoryID LIKE '{0}%'",
productInfo1.CategoryID);
else if (productInfo1.CategoryID == null)
sql.Append(" AND CategoryID IS NULL");
in the case of a productid it can never be null but a category could.
How have you guys done this? The above will always look for categoryid
of null even when i only want to search by productid or i have to
include a category too.
dan