tkrems
asked on
How to check against an empty FoxPro date field like " / / " in c#?
Hi to all,
I have a FoxPro dbf field of type Date and Width 8. This is imported to a DataTable using "CAST(YEAR(MASCH.baujahr) AS CHARACTER(4)) AS zusaetze5". In FoxPro the field looks like " / / ". What value is this from a c# view? How can I check against it?
thanks in advance
I have a FoxPro dbf field of type Date and Width 8. This is imported to a DataTable using "CAST(YEAR(MASCH.baujahr) AS CHARACTER(4)) AS zusaetze5". In FoxPro the field looks like " / / ". What value is this from a c# view? How can I check against it?
thanks in advance
ASKER
Sorry, Olaf. I want to check the field's value in c#, not in sql.
That's what I want to do:
That's what I want to do:
if (row[6].ToString().Trim() == "" | row[6].ToString().Trim() == "/ /")
{
MessageBox.Show (row[6].ToString().Trim());
row[6] = "k.A.";
// row[6] is 'zusaetze5 (year)'
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you both, was a problem with the OleDbDataReader.
The function to check for empty is EMPTY(), so eg you can.
SELECT ... CAST(YEAR(MASCH.baujahr) AS CHARACTER(4)) AS zusaetze5 ... FROM ... WHERE NOT EMPTY(MASCH.baujahr)
What may be problematic is MASCH.baujahr being NULL. But you can check against that with WHERE NOT (MASCH.baujahr IS NULL)
Bye, Olaf.