[WebMethod]
public string[] Search(string prefixText)
{
string sql = "SELECT Proc_Name FROM Process WHERE Proc_Name like @prefixText";
SqlDataAdapter da = new SqlDataAdapter(sql, ConfigurationManager.ConnectionStrings["Audit_SystemConnectionString"].ConnectionString);
da.SelectCommand.Parameters.Add("@prefixText", System.Data.SqlDbType.VarChar, 250).Value = "%" + prefixText + "%";
DataTable dt = new DataTable();
da.Fill(dt);
string[] item = new string[dt.Rows.Count];
int i = 0;
foreach (DataRow dr in dt.Rows)
{
item.SetValue(dr["Proc_Name"].ToString(), i);
i++;
if (i == 5)
{
Array.Resize(ref item, 5);
break;
}
}
Array.Sort(item);
//Array.Resize(ref item, 5);
return item;
}
}