Hi, I'm using Builder c++ 6 and UniDAC to connect to SQL Server.
I need to handle date time values at tenth of milliseconds granularity.
If I try to insert with UniSQL
UniSQL->Params->ParamByName("EventDateTime")->Value = "2015-07-27 11:44:55.1234000";
I have this error
Implicit conversion from data type sql_variant to datetime2 is not allowed. Use the CONVERT function to run this query.'
I need to read too the data with tdatagrid but I get a TDateTime field, but it is only up to milliseconds.
This problem occurs also if I use prNativeClient. Is prOLEDB better?
Which datatype should I use for handling tenth of milliseconds granularity in c++ builder 6?
Thank you
Regards
Alessandro Miorelli
SQL server and datetime2
Re: SQL server and datetime2
Currently, UniDAC maps the datetime2 type to TDateTimeField when using SQL Native Client. This class trims microseconds, and we can't affect this behavior at the moment. We will try to change this behavior in one of the next UniDAC versions.
The standard OLEDB Provider returns the TWideStringField type for the datetime2 data type, and a value in the format 'yyyy-mm-dd hh:mm:ss[.fffffff]' . So you can process the datetime2 data type as a string value with the WideString type using the standard OLEDB Provider.
The standard OLEDB Provider returns the TWideStringField type for the datetime2 data type, and a value in the format 'yyyy-mm-dd hh:mm:ss[.fffffff]' . So you can process the datetime2 data type as a string value with the WideString type using the standard OLEDB Provider.