string sql="select ... where cateBig = '" + ProdBigStr + "'"; 
字符串,都要带单引号!!!

解决方案 »

  1.   

    if (ProdBigStr == "--产品大类--")
    {
    ProdBrandAll = "";
    }
    else if(ProdLitStr == "--产品小类--")
    {
    ProdBrandAll = "cateBig = '" + ProdBigStr + "'";
    }
    else if(ProdBrandStr == "--产品品牌--")
    {
    ProdBrandAll = "cateBig = '" + ProdBigStr + "' and cateLit = '" + ProdLitStr + "'";
    }
    else
    {
    ProdBrandAll = "cateBig = '" + ProdBigStr +  "' and cateLit = '" + ProdLitStr + "' and brand = '" +  ProdBrandStr + "'";
    }if(ProdBigStr != "--产品大类--")
    {  
    StrSql += " where " + ProdBrandAll;
    }

    else
    {
    StrSql = "SELECT brand from CompanyProdCate";
    }记住你一定要记住:字符串拼接后的正确性