public JsonResult getAccountsName(string prefix) { HospitlLocationID(); objbl.Connect(); DataSet ds = new DataSet(); SqlCommand cmd = new SqlCommand("select AccountsID, AccountName from Accounts where HospitalID='" + HospitalID + "' and LocationID='" + LocationID + "' and AccountsID =" + prefix + " and RowStatus=0", objbl.con); cmd.Parameters.AddWithValue("@prefix", prefix); objbl.con.Open(); SqlDataAdapter ad = new SqlDataAdapter(cmd); ad.Fill(ds); objbl.con.Close(); List <VoucherEntry> searchlist = new List <VoucherEntry>(); foreach (DataRow dr in ds.Tables[0].Rows) { searchlist.Add(new VoucherEntry { AccountName = dr["AccountName"].ToString(), AccountsID = dr["AccountsID"].ToString() }); } return(new JsonResult { Data = searchlist, JsonRequestBehavior = JsonRequestBehavior.AllowGet }); }