DataTale中判断某个字段中是否包含某个数据

 

        /// <summary>
        /// 判断DataTale中判断某个字段中包含某个数据
        /// </summary>
        /// <param name="dt"></param>
        /// <param name="columnName"></param>
        /// <param name="fieldData"></param>
        /// <returns></returns>
        public static Boolean IsColumnIncludeData(DataTable dt, String columnName, string fieldData)
        {
            if(dt==null)
            {
                return false;
            }
            else
            {
                 DataRow[] dataRows = dt.Select(columnName+"='"+fieldData+"'");
                 if (dataRows.Length.Equals(1))
                 {
                     return true;
                 }
                 else
                 {
                     return false;
                 }
            }

        }

  

posted @ 2015-12-16 09:39  人生为卒  阅读(336)  评论(0编辑  收藏  举报