MySQL does not return data in a column

2

I have a database where sometimes there is no data in some columns, I would like to know how I could know that this column is null .

I've tried with

  if(!_Rellenar.HasRows) { isNull = false; }

And with:

  if(!_Rellenar.Read()) { isNull = false; }

But in neither case does it work. I'm sure that in these columns, the database is empty, so I can not understand why I can do Read() and HasRows() without returning False .

Thanks in advance.

    
asked by Georgia Fernández 14.10.2018 в 23:05
source

1 answer

2

Keeping in mind that _Rellenar is of type MySqlDataReader can not ask in this for a columan, since it represents the complete record

If you are going to ask for a column you would use

MySqlDataReader _Rellenar = cmd.ExecuteReader();

if(_Rellenar.Read()){

     if(_Rellenar["nombreColumna"] != DBNull.Value){
         var contenido = Conver.ToString(_Rellenar["nombreColumna"]);
      }

}

something like that would apply to know if the column contains a null value or not

    
answered by 15.10.2018 / 01:35
source