Page 1 of 1

Mapping date field

Posted: Thu 20 Dec 2012 11:51
by robsonmbobbi
Hi.

I'm using the driver version 6.0.1. I have some fields in SQL Server 2008 database of type date, that are mapped for TWideString, and not for TDateTime.

In my project, I'm using TSQLConnection, and I've already used sqlncli10.dll, sqlncli.dll, sqlncli10.dll and sqloledb.dll in VendorLib property.

Re: Mapping date field

Posted: Thu 20 Dec 2012 14:43
by AndreyZ
Hello,

This problem is caused by the OLEDB provider. The OLEDB provider returns DATE columns in the string format. To solve the problem, you should use SQL Native Client provider. For this, you should set the TSQLConnection.VendorLib property to sqlncli.dll . If you have persistent fields in datasets work with DATE columns, you should recreate persistent fields in these datasets. After this, all DATE columns will be mapped to TDateField.

Re: Mapping date field

Posted: Thu 20 Dec 2012 17:39
by robsonmbobbi
AndreyZ,

I used sqlncli.dll in VendorLib property, but not work. In my machine I've installed MS SQL Server 2008 R2 with Native Client sqlncli10.dll version 10.50.2500.0.

Configuration used in Delphi XE3:

Code: Select all

 with SQLConnection do
     begin
       DriverName                                := 'DevartSQLServer';
       GetDriverFunc                             := 'getSQLDriverSQLServer';
       LibraryName                               := 'dbexpsda40.dll';
       VendorLib                                 := 'sqlncli.dll';
       Params.Values['DriverName']               := 'DevartSQLServer';
       Params.Values['Database']                 := Copy(sDataBase, Pos(':', sDataBase) + 1, Length(sDataBase) - Pos(':', sDataBase));
       Params.Values['HostName']                 := Copy(sDataBase, 1, Pos(':', sDataBase) - 1);
       Params.Values['User_Name']                := Usuario;
       Params.Values['Password']                 := Senha;
       Params.Values['IsolationLevel']           := 'DirtyRead'; 
end;
What Am I doing wrong and what is the issue?

Re: Mapping date field

Posted: Fri 21 Dec 2012 10:03
by AndreyZ
In RAD Studio XE3, you should specify VendorLib in the connection parameters. Here is a code example:

Code: Select all

SQLConnection.Params.Values['VendorLib'] := 'sqlncli.dll';
For more information about such behaviour, please consult with Embarcadero developers.

Re: Mapping date field

Posted: Fri 21 Dec 2012 13:27
by robsonmbobbi
AndreyZ, thank you.
The problem was solved.

Re: Mapping date field

Posted: Fri 21 Dec 2012 13:45
by AndreyZ
I am glad I could help. If any other questions come up, please contact us.