views:

278

answers:

2

Some days ago I posted a question on which component to use to make a MultiDatabaseWithJustOneComponent and i follow the general advice to use dbexpress.

FirebirdSQL has date field, SQL Server 2008 has date fields too. But for some reason date fields are converted to TWideStringField, and when I'm trully confident that I've seen all error messages in delphi like 'catastrofic failure', I've got new ones. ;-)

D2010 seems to have this 'bug' corrected, but i don´t have extra large cash to deal with it, so... does anyone have any ideia?

Thanks in advance.

A: 

Manually set the field.FieldType type to TDateTimeField. This just means that for whatever reason DBExpress is autodetecting the field type incorrectly. Override it and it should be fine.

Donnie
i´m using a routine to create TSQLQuery, TDataSetProvider and TClientDataSet at runtime. When i should add this fix? Tnx.
José Eduardo
+4  A: 

When Delphi 2006 was released, SQL server didn't have a date field type, only DateTime. (Date and Time fields were added with SQL Server 2008). As a result the DBExpress drivers in D2006 don't know how to deal with them.

Your best bet may be to coerce the date fields to DateTime (or SmallDateTime) using CAST or CONVERT, then D2006 will know how to deal with them.

SELECT CAST(DateField as DateTime)

OR 

SELECT CONVERT(DateTime, DateField)

Alternatively use DateTime or SmallDateTime fields in your DB schema if possible. SQL Server DateTime is similar to Delphi's TDateTime.

Another possibility is to covert to the dbGO (ADO components), but this would require more rework.

Gerry