Mapping date field

Discussion of open issues, suggestions and bugs regarding usage of dbExpress drivers for SQL Server in Delphi and C++Builder
Post Reply
robsonmbobbi
Posts: 3
Joined: Thu 20 Dec 2012 11:03

Mapping date field

Post by robsonmbobbi » Thu 20 Dec 2012 11:51

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.

AndreyZ

Re: Mapping date field

Post by AndreyZ » Thu 20 Dec 2012 14:43

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.

robsonmbobbi
Posts: 3
Joined: Thu 20 Dec 2012 11:03

Re: Mapping date field

Post by robsonmbobbi » Thu 20 Dec 2012 17:39

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?

AndreyZ

Re: Mapping date field

Post by AndreyZ » Fri 21 Dec 2012 10:03

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.

robsonmbobbi
Posts: 3
Joined: Thu 20 Dec 2012 11:03

Re: Mapping date field

Post by robsonmbobbi » Fri 21 Dec 2012 13:27

AndreyZ, thank you.
The problem was solved.

AndreyZ

Re: Mapping date field

Post by AndreyZ » Fri 21 Dec 2012 13:45

I am glad I could help. If any other questions come up, please contact us.

Post Reply