/* */

Sql Reqder Check Column Name exist or Not.

For good . Add this in a class if static.


 public static bool IsColumnExists(this IDataReader dataReader, string columnName)
        {
            bool retVal = false;

            try
            {
                dataReader.GetSchemaTable().DefaultView.RowFilter = string.Format("ColumnName= '{0}'", columnName);
                if (dataReader.GetSchemaTable().DefaultView.Count > 0)
                {
                    retVal = true;
                }
            }

            catch (Exception ex)
            {

                throw;
            }

            return retVal;
        }

Validate from your cs file .
Previous
Next Post »
Thanks for your comment