Page 1 of 1

SQL Server Date field and NetworkLibrary

Posted: Sat 01 Nov 2014 17:23
by JimMellish
I have a program with the following code:

UniQuery.SQL.Text := 'select * from Test';
UniQuery.Open;
for i := 0 to UniQuery.FieldCount - 1 do
Memo.Lines.Add (IntToStr(i) + ' ' +
UniQuery.Fields.FieldName + ' ' +
GetEnumName(TypeInfo(TFieldType),Ord(UniQuery.Fields.DataType)));

With NetworkLibrary set to prNativeClient (or prAuto) I get the following result:

0 IntColumn ftInteger
1 VarCharColumn ftString
2 DateTimeColumn ftDateTime
3 SmallDateTimeColumn ftDateTime
4 DateColumn ftDate

With NetworkLibrary set to prSQL I get the following result:

0 IntColumn ftInteger
1 VarCharColumn ftString
2 DateTimeColumn ftDateTime
3 SmallDateTimeColumn ftDateTime
4 DateColumn ftWideString

The date column has changed from ftDate to ftWideString. Is this a bug (or feature !) in the Microsoft libraries and if so is there a work around ?

Re: SQL Server Date field and NetworkLibrary

Posted: Mon 03 Nov 2014 10:00
by azyk
The point is that the standard OLEDB provider processes date fields as string fields. If you need to map the date data type to ftDdate, you can use Data Type Mapping. For example, in the dataset before opening it:

Code: Select all

UniQuery.DataTypeMap.AddFieldNameRule('DateColumn', ftDate);
More details about Data Type Mapping can be found in our documentation: http://www.devart.com/unidac/docs/index ... apping.htm .

Re: SQL Server Date field and NetworkLibrary

Posted: Tue 04 Nov 2014 09:40
by JimMellish
I think we will have to insist that NativeClient is used. We have too many queries, with some of them being generated automatically, to apply data type mapping to every query with a date in its result set.

Re: SQL Server Date field and NetworkLibrary

Posted: Wed 05 Nov 2014 07:44
by AlexP
Yes, in your case, it is better to use NativeClien.