Board index » delphi » Reading NULL values

Reading NULL values

Hi,

I have a problem with NULL values when reading field values from SQL
Server 2000 through an ADO query.

My code looks something like this:

      try
        field := adoq.FieldByName(asName);
      except
        raise EEzODatasetFieldNotFound.Create('Field ' + asName +
          ' not found.', self);
      end;
      try
        if field.IsNull then
          result := avDefault
        else
          result := field.AsVariant;
      except
        raise EEzODatasetFieldRead.Create('Value for field ' + asName +
          ' could not be read.', self);
      end;

The statement fied.IsNull does not work. If I read a field with a NULL
value I get an EVariantError.

What is the problem?

 

Re:Reading NULL values


What is the data type of the variable Field?

--
Bill
(TeamB cannot answer questions received via email)

Re:Reading NULL values


Now I remark that I get problems even if the field isn't null. I have
problems with datetime and ntext fields.

Re:Reading NULL values


Can you be more specific about the problems you are experiencing? Please
tell us what database you are using, what error message you are getting and
which data access components you are using.

--
Bill
(TeamB cannot answer questions received via email)

Other Threads