Testing and reacting to NULL values
Posted: Wed 03 Aug 2016 08:03
In my table I have a field called closed.
If the case is closed it will contain the date it was closed otherwise it remains empty.
I search my DB for a case finishing my query with
so it only displays open cases.
My Query also converts the closed date
However, having executed the query and it returns no results it's possibly one of two things.
Either the case does not exist or the case is closed.
I need to know if this Field had a value so I can pop up a message
to the user to advise them that IT IS a CLOSED case.
I have tried the following two commands without success....
If I search for a known closed case both commands above return nothing in IsClosed.
I use both of the above in other parts of my code without problem.
Any Ideas....
If the case is closed it will contain the date it was closed otherwise it remains empty.
I search my DB for a case finishing my query with
Code: Select all
"and closed is null" My Query also converts the closed date
Code: Select all
convert(varchar(12), closed,103) as closedEither the case does not exist or the case is closed.
I need to know if this Field had a value so I can pop up a message
to the user to advise them that IT IS a CLOSED case.
I have tried the following two commands without success....
Code: Select all
var IsClosed : String;
IsClosed := DBSearchGrid.DataSource.DataSet.FieldByName('closed').AsString;
If IsClosed <> '' Then ShowMessage('Case is a CLOSED Case');
IsClosed := DBSearchGrid.DataSource.DataSet.Fields.Fields[13].AsString;
If IsClosed <> '' Then ShowMessage('Case is a CLOSED Case');I use both of the above in other parts of my code without problem.
Any Ideas....