后台 using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Data; using System.Data.SqlClient;
public partial class AutoCompleteExtender : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) {
}
[System.Web.Services.WebMethodAttribute(), System.Web.Script.Services.ScriptMethodAttribute()] public static string[] GetCompletionList(string prefixText, int count, string contextKey) { SqlConnection conn = new SqlConnection("Server=(Local);Uid=sa;pwd=15911113281;DataBase=db_Siemens"); SqlCommand cmd; string cmdString = "select UserName from t_StaffInfo WHERE UserName LIKE '" + prefixText + "%'"; // "Select CompanyName from Customers WHERE CompanyName LIKE '" + // prefixText + "%'"; //conn = new SqlConnection(ConfigurationManager.AppSettings["conStr"]); //// Put this string on one line in your code cmd = new SqlCommand(cmdString, conn); conn.Open();
SqlDataReader myReader; List<string> returnData = new List<string>();