我有一个自动扩展程序,我希望结果可以同时附带
[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
中,这个不起作用的PLZ帮助我
答案 0 :(得分: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 + "%");