-2

我有一个自动扩展器,我希望结果应该同时带有

 [System.Web.Script.Services.ScriptMethod()]
        [System.Web.Services.WebMethod]
        public static List<string> Get_challan(string prefixText)
        {
            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["BMS"].ToString());
            con.Open();
            SqlCommand cmd12 = new SqlCommand("select distinct(product_accessories),delivery_cann from hardware where delivery_cann like @Name+'%' and **suppl_type=3**", con);
            cmd12.Parameters.AddWithValue("@Name", prefixText);
            SqlDataAdapter da12 = new SqlDataAdapter(cmd12);
            DataTable dt12 = new DataTable();
            da12.Fill(dt12);
            List<string> CountryNames12 = new List<string>();
            for (int i = 0; i < dt12.Rows.Count; i++)
            {
                CountryNames12.Add(dt12.Rows[i][1].ToString());
            }
            return CountryNames12;
        }

在上面的代码中,suppl_type=3这不起作用请帮助我

4

1 回答 1

0

我认为你的sql是错误的,试试这个。通配符之类的可以在 parameters.addwithvalue 中解决

SqlCommand cmd12 = new SqlCommand("select distinct product_accessories,delivery_cann from hardware where delivery_cann like @Name and suppl_type=3", con);
cmd12.Parameters.AddWithValue("@Name", "%" + prefixText + "%");
于 2013-10-18T09:56:09.087 回答