public string[] GetCompletionList(string prefixText, int count) { // DB cn = new DB(); conn(); DataTable dt = new DataTable(); DataSet ds = new DataSet(); try { string text = "%" + prefixText + "%"; cmd = new SqlCommand("select * from product where name like '" + text + "'", con); da = new SqlDataAdapter(cmd); ds = new DataSet(); da.Fill(ds); // ds = cn.getDataSet("select * from reg where Firstname like '" + text + "'", "reg"); } catch { } finally { } dt = ds.Tables[0]; //Then return List of string(txtItems) as result List<string> txtItems = new List<string>(); String dbValues; String img; String email; foreach (DataRow row in dt.Rows) { //String From DataBase(dbValues) dbValues = row["Email"].ToString(); //dbValues = dbValues.ToLower(); //txtItems.Add(dbValues,); img = row["image"].ToString(); img = img.Remove(0, 2); //txtItems.Add(img); txtItems.Add(AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(dbValues.ToString(), img.ToString())); // txtItems.Add(AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(dbValues.ToString())); } return txtItems.ToArray(); } }
dt=ds.table[0];
Error msg : Cannot find table 0.
If(ds != null && ds.tables.count > 0) { dt = ds.Tables[0] }
SqlDataAdapter sdaAdapter = new SqlDataAdapter(); sdaAdapter.SelectCommand = new SqlCommand("select * from product where name like '" + text + "'", con); sdaAdapter.SelectCommand.CommandType =CommandType.Text; DataTable dtTable = new DataTable(); sdaAdapter.Fill(dtTable);
da.fill(ds,"write table name hear")
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)