[System.Web.Script.Services.ScriptMethod]
[System.Web.Services.WebMethod]
public static string[] SearchCustomers(string prefixText, int count)
{
using (SqlConnection conn = new SqlConnection())
{
conn.ConnectionString = ConfigurationManager.ConnectionStrings["Ebazzar"].ConnectionString;
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandText = "select pname from products where pname like @SearchText";
cmd.Parameters.AddWithValue("@SearchText", prefixText + "%");
cmd.Connection = conn;
conn.Open();
List<string> Products = new List<string>();
using (SqlDataReader sdr = cmd.ExecuteReader())
{
while (sdr.Read())
{
Products.Add(sdr["pname"].ToString());
}
}
conn.Close();
return Products.ToArray();
}
}
}