using System.Data; using System.Data.SqlClient; using System.Collections.Generic; using System.Configuration; using System; using System.Data.SqlServerCe; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } [System.Web.Script.Services.ScriptMethod()] [System.Web.Services.WebMethod] public static List<string> GetCompletionList(string prefixText) { SqlCeConnection con = new SqlCeConnection(ConfigurationManager.ConnectionStrings["ConnectionString"].ToString()); con.Open(); SqlCeCommand cmd = new SqlCeCommand("SELECT Name FROM Current WHERE Name LIKE @Name+'%'", con); cmd.Parameters.AddWithValue("@Name", prefixText); SqlCeDataAdapter da = new SqlCeDataAdapter(cmd); DataTable dt = new DataTable(); da.Fill(dt); List<string> Names = new List<string>(); for (int i = 0; i < dt.Rows.Count; i++) { Names.Add(dt.Rows[i][1].ToString()); } return Names; } }
param.Value = "%" + parameter.Value + "%";