TUniQuery 's execute function giving exception while using AsSQLTimeStampOffset as data typpe for query parameter

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
rupendra
Posts: 4
Joined: Fri 15 Sep 2017 09:58

TUniQuery 's execute function giving exception while using AsSQLTimeStampOffset as data typpe for query parameter

Post by rupendra » Fri 15 Sep 2017 10:17

I am using insert query for posting data from embarcadero(firebird as DB) to SQL server using Unidac.
I am using the following query as a parameter for storing TSQLTimeStampOffset data type.

UQuery->ParamByName("DayLightTimeOfET")->AsSQLTimeStampOffset = PModels.DayLightTimeOfET;

where "UQuery " is a pointer to TUniQuery and "PModels" is a class and DayLightTimeOfET is variable of data type SQLTimeStampOffset of PModels class.

while executing the query I am getting the following exception.

"Invalid internal field type $19 (25) (D:\Projects\Delphi\Dac\SqlServer\Source\OLEDBAccess.pas, line 1214)"
Can Anyone help? my other queries are working fine.

azyk
Devart Team
Posts: 1119
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: TUniQuery 's execute function giving exception while using AsSQLTimeStampOffset as data typpe for query parameter

Post by azyk » Mon 18 Sep 2017 07:25

Please specify the data type you are using in the Firebird table and in the SQL Server table.

rupendra
Posts: 4
Joined: Fri 15 Sep 2017 09:58

Re: TUniQuery 's execute function giving exception while using AsSQLTimeStampOffset as data typpe for query parameter

Post by rupendra » Mon 18 Sep 2017 07:30

In SQlServer data type is DateTimeOffset and i am creating a new datatype in firebird ie; TSQLTimeStampOffset.
Note: I am not using it in firebird DB Table.

azyk
Devart Team
Posts: 1119
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: TUniQuery 's execute function giving exception while using AsSQLTimeStampOffset as data typpe for query parameter

Post by azyk » Mon 18 Sep 2017 13:25

You can work with the data type datetimeoffset as with a string value, presented in the format

Code: Select all

YYYY-MM-DD hh:mm:ss[.nnnnnnn] [+|-]hh:mm 
For this, you need set the 'Provider' option to 'prSQL'.

For example:

Code: Select all

UniConnection1->SpecificOptions->Values["SQL Server.Provider"] = "prSQL";
...
UQuery->ParamByName("DayLightTimeOfET")->DataType = ftWideString;
UQuery->ParamByName("DayLightTimeOfET")->AsString = SQLTimeStampOffsetToStr("YYYY-MM-DD hh:mm:ss", PModels.DayLightTimeOfET);

rupendra
Posts: 4
Joined: Fri 15 Sep 2017 09:58

Re: TUniQuery 's execute function giving exception while using AsSQLTimeStampOffset as data typpe for query parameter

Post by rupendra » Tue 19 Sep 2017 03:15

Yesterday i got following from your page.
"yyyy-mm-dd hh:nn:ss"
It works.


Post Reply