public JsonResult GetColumnFromSQL() { string id = QueryString("listId"); ListConfig list = UnitOfWork.GetByKey <ListConfig>(id); list.CheckNotNull("ListConfig"); string connName = WebConfigHelper.GetConnSettingNameByDBName(list.DBName); if (!string.IsNullOrEmpty(list.TableName) && !string.IsNullOrEmpty(connName)) { string sql = string.Format("select top 1 * FROM {0}", list.TableName); SqlHelper sqlHelper = new SqlHelper(connName); var dt = sqlHelper.ExcuteTable(sql); List <string> colNames = new List <string>(); foreach (DataColumn dc in dt.Columns) { colNames.Add(dc.ColumnName); } if (colNames.Count() > 0) { return(Json(colNames)); } } return(Json(false)); }