public string[] GetCountry(string prefixText) { //Retieve connection string from config file and assigned in to the sqlconnection SqlConnection sqlcon = new SqlConnection(ConfigurationManager.ConnectionStrings["conn"].ConnectionString); SqlCommand sqlcmd = new SqlCommand(); DataSet ds = new DataSet(); //write query to get country name based on user entered text string query = "select Name from hospital_hospitaladd where Name like '" + prefixText + "%' "; sqlcmd = new SqlCommand(query, sqlcon); sqlcon.Open(); SqlDataAdapter da = new SqlDataAdapter(); da.SelectCommand = sqlcmd; da.Fill(ds); //Create one array variable and set size based on return datatable row count string[] cname = new string[ds.Tables[0].Rows.Count]; //string[] category = new string[ds.Tables[0].Rows.Count]; int i = 0; try { foreach (DataRow dr in ds.Tables[0].Rows) { //assign each value in to the array variable cname.SetValue(dr["Name"].ToString(), i); //cname.SetValue(dr["category"].ToString(), i); i++; } } catch (Exception ex) { } finally { sqlcon.Close(); } //Lastreturn that array values for bind in extender return cname; }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)