[WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] // To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. [System.Web.Script.Services.ScriptService] public class AutoCompleteWebService : System.Web.Services.WebService { public AutoCompleteWebService () { //Uncomment the following line if using designed components //InitializeComponent(); } [WebMethod] public string[] AutoCompleteAjaxRequest(string prefixText, int count) { List<string> ajaxDataCollection = new List<string>(); DataTable _objdt = new DataTable(); _objdt = GetDataFromDataBase(prefixText); if(_objdt.Rows.Count>0) { for (int i = 0; i < _objdt.Rows.Count; i++) { ajaxDataCollection.Add(_objdt.Rows[i]["spename"].ToString()); } } return ajaxDataCollection.ToArray(); } public DataTable GetDataFromDataBase(string prefixText) { string connectionstring = "Data Source=localhost;Initial Catalog=DoctorAppointment;User ID=sa;Password=abc;"; DataTable _objdt = new DataTable(); string querystring = "select spename from tbl_spe where spename like '%" + prefixText + "%';"; SqlConnection _objcon = new SqlConnection(connectionstring); SqlDataAdapter _objda = new SqlDataAdapter(querystring, _objcon); _objcon.Open(); _objda.Fill(_objdt); return _objdt; } [WebMethod] public string[] AutoCompleteAjaxRequestLoc(string prefixText, int count) { List<string> ajaxDataCollection = new List<string>(); DataTable _objdt = new DataTable(); _objdt = GetDataFromDataBase1(prefixText); if (_objdt.Rows.Count > 0) { for (int i = 0; i < _objdt.Rows.Count; i++) { ajaxDataCollection.Add(_objdt.Rows[i]["loc"].ToString()); } } return ajaxDataCollection.ToArray(); } public DataTable GetDataFromDataBase1(string prefixText) { string connectionstring = "Data Source=localhost;Initial Catalog=DoctorAppointment;User ID=sa;Password=abc;"; DataTable _objdt = new DataTable(); string querystring = "select loc from tbl_loc where loc like '%" + prefixText + "%';"; SqlConnection _objcon = new SqlConnection(connectionstring); SqlDataAdapter _objda = new SqlDataAdapter(querystring, _objcon); _objcon.Open(); _objda.Fill(_objdt); return _objdt; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)