Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.


Welcome, Guest
Guest Settings
Help

Thread: Type Mismatch field 'EventDate' expecting: Date actial:Widestring


This question is answered. Helpful answers available: 2. Correct answers available: 1.


Permlink Replies: 6 - Last Post: Apr 17, 2015 5:06 AM Last Post By: Barry Wood
Barry Wood

Posts: 21
Registered: 7/16/01
Type Mismatch field 'EventDate' expecting: Date actial:Widestring  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 13, 2015 7:22 AM
Hi
In an SQL database I have a field with a data type of ‘Date’. In FireDAC I have this field also setup as a TDateField.

I have used LiveBindings to connect a TEdit to the ‘EventDate’ data field, which is where I imagine the problem comes from. What I can’t understand is why it works fine on my local copy of SQL and the ‘live’ SQL Server from my own laptop (which is using Delphi XE5) but gives an error message when run on a clients PC. On a Users PC I get an error message ‘Exception eDatabaseError in module …. At ….., fdqCalendar: Type mismatch for field ‘EventDate’, expecting: Date actual: Widestring’

Nowhere can I find this field set up to be a WideString, so how is LiveBindings manageing this?

If I change the field from a TEdit to a TDateTimePicker and link that with LiveBindings, and try to add a record I get an ‘EvalError in LinkControlToFieldEventDate: ‘’ is not a valid date and time’.

Also, doesn’t FireDAC sort out the compatibility of data types when using LiveBindings?

I've also posted this question in the LiveBindings forum, as it seems relevant to both areas.
Dmitry Arefiev

Posts: 1,406
Registered: 12/7/03
Re: Type Mismatch field 'EventDate' expecting: Date actial:Widestring  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 14, 2015 8:11 AM   in response to: Barry Wood in response to: Barry Wood
I have used LiveBindings to connect a TEdit to the ‘EventDate’ data field, which is where I imagine the problem comes from. What I can’t understand is why it works fine on my local copy of SQL and the ‘live’ SQL Server from my own laptop (which is using Delphi XE5) but gives an error message when run on a clients PC. On a Users PC I get an error message ‘Exception eDatabaseError in module …. At ….., fdqCalendar: Type mismatch for field ‘EventDate’, expecting: Date actual: Widestring’

This issue is probably due to a difference in SQL Server client library versions.
Get a FireDAC environment report on your laptop:
http://docwiki.embarcadero.com/RADStudio/XE8/en/DBMS_Environment_Reports_(FireDAC)
Then get it on a user PC and compare. Probably you should install SQL Server
Native Client on a user PC.

Also, doesn’t FireDAC sort out the compatibility of data types when using LiveBindings?

This is not FMX / LiveBindidings specific. This is data access components issue.
The original exception is raised inside of TDataSet code. The solution - to unify
field types accross all deployment systems.

--
With best regards,
Dmitry Arefiev / FireDAC Architect
Barry Wood

Posts: 21
Registered: 7/16/01
Re: Type Mismatch field 'EventDate' expecting: Date actial:Widestring  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 15, 2015 6:24 AM   in response to: Dmitry Arefiev in response to: Dmitry Arefiev
I've done some more testing of this issue to try to identify where the problems lies. I've built a small VCL project with a TDateTimePicker, TEdit, TBindNavigator, TStringGrid. These I connect to an MS SQL table which has one field - a Date field. The idea was to compare how a TDateTimePicker and a TEdit field differ when bound to a SQL Date field.

After I connect the grid, navigator and TEdit with LiveBindings I can add, amend, and delete to the field. Works fine.

When I connect the TDateTimePicker to the field in place of the TEdit and try to add a record I get 'EvalError in LinkControlToField3: " is not a valid date and time'. I can amend or delete an existing record using this TDateTimePicker control, but I can't add a new record. Looking at the error message it appears that this control requires a valid date to be in it before an add can take place. I just wish I had a TDBDateTimePicker as once I did, I never had this issue before :-).

I tried to insert a valid date in this control on the navigator click event if insert was selected but the error is thrown up before this event is fired.

Thanks for the response, Dmitry, but on testing more thoroughly I found I was getting the same error on my laptop as the User so I doubt it is a dissimilarity between the SQL client library. I have SQL Server on my laptop and at the ISP hosting company - I get the same error from either location.
Dmitry Arefiev

Posts: 1,406
Registered: 12/7/03
Re: Type Mismatch field 'EventDate' expecting: Date actial:Widestring  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 16, 2015 4:07 AM   in response to: Barry Wood in response to: Barry Wood
Ok, got it. This issue was fixed 1-2 RAD Studio versions ago. On XE8 I cannot reproduce this issue.

--
With best regards,
Dmitry Arefiev / FireDAC Architect
Barry Wood

Posts: 21
Registered: 7/16/01
Re: Type Mismatch field 'EventDate' expecting: Date actial:Widestring  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 16, 2015 11:45 AM   in response to: Dmitry Arefiev in response to: Dmitry Arefiev
So this is a fault with XE5 then? Shouldn't there be a fix if it is a fault? Something about 'fit for purpose', if a fault is found a fix should be provided, not a very expensive upgrade to the next level. Delphi is already moving out of reach of the developer community that made it so popular 15 years ago because of so many expensive version upgrades.

What I'll do is disconnect the TDateTimePicker from the database and manipulate the values entered in it to populate the SQL Date field - this wasn't necessary in Delphi 2006 when I could use a perfectly good TDBDateTimePicker component.
Barry Wood

Posts: 21
Registered: 7/16/01
Re: Type Mismatch field 'EventDate' expecting: Date actial:Widestring  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 17, 2015 3:36 AM   in response to: Barry Wood in response to: Barry Wood
This is getting more frustrating now.

I've 'disconnected' the TDateTimePicker from the SQL Date field and coded an intermediary step, adding the value entered in the TDateTimePicker to the Date field in SQL when posting a new or edited record. This works perfectly on my development machine (Chillblast .Windows 8.1 Pro 64bit).

However, when I try on the clients PC (running Windows 8.1 Home 64bit) I get the error message again about Type Mismatch ... expecting Date actual: Widestring. This is before the application actually comes up, never mind getting to the add/edit/delete parts of the project. This is when the application is initialising - I presume matching up the datasource with the SQL table.

Now the odd thing I don't get this error on my machine, but the User does on his. Both of us are connecting to the same SQL instance. It isn't a case of us trying to connect to different SQL instances, so I'm at a loss as to why the application errors on his PC but not on mine.

I have also tried this application on three other units: my corporate laptop ( a Dell running Windows 7 Professional 64bit) - I get the Type Mismatch error, a Chillblast PC (Windows 8.1 Home Premium 64bit) and my old laptop (Windows 8.1 Pro 64bit) - it runs perfectly on both of these, yet not on the Dell.

What is it that exists or doesn't exist on some units but doesn't or does on others that can create this error? And is there a 'simple' way to 'force' the field matching to remove this 'Widestring' issue, as the fields in question are all Date fields and not string fields?

Any help would be appreciated - I'd hate to go back to ADO (and perhaps Delphi 2010 - as I was upgrading this application from Delphi 2010 were it has worked perfectly for years - if ADO shows the same issues) and bypass FireDAC but that seems the next step.
Barry Wood

Posts: 21
Registered: 7/16/01
Re: Type Mismatch field 'EventDate' expecting: Date actial:Widestring  
Click to report abuse...   Click to reply to this thread Reply
  Posted: Apr 17, 2015 5:06 AM   in response to: Barry Wood in response to: Barry Wood
Think I have a clue here - the issue seems to be with SQL 2008 and it's introduction of a Date datatype and how this gets interpreted.

I see an option to fix as installing SQL Native Client (my application works where I have this installed, and gives the error on those units which don't). There's another option about mapping types, but I've tried this and it doesn't appear to work for me. Installing SQL Natice Client on my User machine seems a bit over the top though.
Legend
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02