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

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.
0
Barry
4/13/2015 2:22:58 PM
embarcadero.delphi.firedac 822 articles. 2 followers. Follow

6 Replies
961 Views

Similar Articles

[PageSpeed] 12

> 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
0
Dmitry
4/14/2015 3:11:20 PM
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.
0
Barry
4/15/2015 1:24:56 PM
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
0
Dmitry
4/16/2015 11:07:23 AM
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.
0
Barry
4/16/2015 6:45:36 PM
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.
0
Barry
4/17/2015 10:36:28 AM
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.
0
Barry
4/17/2015 12:06:12 PM
Reply:

Similar Artilces:

Type mismatch for field 'xxx', expecting: WideString actual: String
Development Enviornment Delphi XE2 oci.dll 11.2.0.1 sqlncli10.dll 2007.100.2531.0 MS SQL Server 2000, 2005, 2008. Collated Arabic_CI_AS Oracle 11g NLS Characterset WE8ISO8859P1 Application using datasnap/dbexpress driver Windows XP Problem Area We have an application that we are converting to runs on both Oracle and MS SQL Server. The Oracle driver brings back Varchar2 as TWideStringField. The SQL Server driver brings back Varchars as TStringField. This becomes a problem for our persistent fields. The error we receive is "Type mismatch for field 'xxx', ex...

Cast from type ''''DBNull'''' to type ''''String'''' is not valid.
How do I avoid getting this error: Cast from type ''''DBNull'''' to type ''''String'''' is not valid. I am trying to get values from the database into a form for updating using a Datareader, SQL is set to allow nulls for certain fields as they are not required but the only way I can get the form to display is by adding a space in SQL. Is there another way around this? Check if it is equal to DBNull.Value first and if it is, don't do the cast.Stanley Tan theSpoke Blog Where in the code does it need to go? I am using the following and it's the profile that isn't always requi...

Cast from type 'DBNull' to type 'Date' is not valid
Hi all, I have this code in DataAccessLayer.vb Dim NuovaScadenza As New Scadenza(CInt(returnData("IdScadenza")), Cint(returnData("IdImpegno")), Cstr(returnData("Descrizione")), CDate(returnData("DataOriginale")) but the field DataOriginale often is empty. In browser it shows this error: Cast from type 'DBNull' to type 'Date' is not valid I have tried with .ToString() but don't work. PLEASE HELP ME! Try using this. If Not IsDBNull(returnData("DataOriginale")) Then ' Do something ...

Conversion from type 'DBNull' to type 'Date' is not valid.
I'm having a problem with a date time field that is null in the database table in SQL Server when it is retrieved using a 2005 tableadapter strong type data set.  I'm trying to set a date control to the null value where the control can handle it but the error (Conversion from type 'DBNull' to type 'Date' is not valid.) occurs from the xsd code. From the data set editor I have an option to change a DefaultValue and it is default to <DBNULL> and it does not let me change it, but also the AllowDBNull property is set to true.  I would appreciate ...

Conversion from type 'TimeSpan' to type 'Date' is not valid.
I am loading data from a mysql database and when it gest to the ltime field it throws the error. "Conversion from type 'TimeSpan' to type 'Date' is not valid." The property of my clsLogItem ltime is declared as DateTime.  Is there something else I should be declaring it as?  Or should I convert the date from the database to something before setting the property equal to it? Public Function GetLog() As List(Of clsLogItem) Dim log As New List(Of clsLogItem) Dim conn As New MySqlConnection(Me.ConnectionString) Dim ...

Conversion from type 'Date' to type 'Boolean' is not valid.
I have a DetailsView and a GridView on my page. When the user clicks "Select" on the GridView, the DetailsView mode gets set to ReadOnly (the Item Template).However, right now when I click "Select" I am receiving the following error Conversion from type 'Date' to type 'Boolean' is not valid. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. Exception Details:...

Cast from type 'Field' to type 'String' is not valid
I am getting the error msg on this code...Response.Write(objRSCount("iCount") & " records for " & frmDispOption & " '" & frmText & "'. They are listed below:")I have tried converting the frmDispOption and frmText variables to strings using CStr after getting the values from the DB but still get the same msg.  Can someone please help me out, thanks.David. What is "objRSCount"? ie what type is it? You also need to make sure that objRSCount("iCount") is string.ThanksMark post(s) as "Answer" that helped youElectronic ScrewWebsite||Blog||Dub@i.net Hi, i f...

Conversion from type 'DBNull' to type 'Date' is not valid.
I have a Date/Time field in an Access DB that was not a required field upon Input. Hence the following formatting only works when there is a date in the DB row.   <ItemTemplate>       <asp:Label ID="Label3" runat="server"             Text='<%# FormatDateTime(DataBinder.Eval(Container.DataItem, “MyLastUpdateDate"),2) %>'       </asp:Label> </ItemTemplate>   Is there any way I can check in my CodeBehind whether or not there is a Date in the fiel...

Conversion from type 'DBNull' to type 'Date' is not valid
I'm using VWD 2005 and have a grid on the page. In that grid, there'sa column that is of date/time type. Nulls are allowed in this column.I'm having problems when trying to edit this date column.I've converted the column to a template and changed theEditItemTemplate from a textbox to a calendar. If a date previouslyexisted for the record being edited, the update action works. If thedate was previously NULL and then a date is chosen via the calendar I get the error. How do I work around this? Charlie Here's my code line:<EditItemTemplate> <asp:Calendar ID="Calendar1" run...

Cannot convert type 'type' to 'type'
I am learning all of this, so I am still fresh, so please bear with me :)I have a page that has some txtboxes in it, simple registration form, and I have a button that will save those txt boxes to the db. I am using:- I am using Visual Web Developer 2008 Express Edition- C# When I try to compile the project I get error: Cannot convert type 'System.Web.UI.WebControls' to 'String' This is content of my web.config    <profile> <properties> <add name="FirstName"/> <add name="LasttName"/>...

Type mismatch for field 'FieldName', expecting: AutoInc actual: LongWord
Hi, I get this error message with AnyDAC (FireDac) components. To show my error, I reduce my mysql table to the minimum. I have two MySQL table who contains many fields of type (string, integer, datetime etc...). The first table named "ReportLog" contain three fields: 'ID' (INTEGER AutoIncrement) 'RptDateTime' (DATETIME) 'fk_OperatorLog' (INTEGER) The second table named "OperatorLog" contain two fields: 'OperId' (INTEGER AutoIncrement) 'DKeyId' (VARCHAR) I put a TFDQuery (na...

''''''''''''''''''''
Name: haznen Email: haznenatyahoodotcom Product: Gran Paradiso Alpha 8 Summary: '''''''''''''''''''' Comments: '''''''''''''''''''''''''''''''''''' Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20061204 UGES/1.7.2.0 GranParadiso/3.0a1 From URL: http://www.mozilla.org/projects/granparadiso/ Note to readers: Hendrix gives...

Conversion from type 'DBNull' to type 'Date' is not valid #2
I am using a MySQL database (where the date is stored in the format YYYY-MM-DD).Therefore in order for the date to be displayed to the user in the desired British format (DD/MM/YYYY) i am utilizing the following code<%# CType(DataBinder.Eval(Container.DataItem, "mydate"), DateTime).ToString("dd/MM/yyyy") %> However, this is clearly problematic where the 'mydate' field is NULL resulting in the error messageConversion from type 'DBNull' to type 'Date' is not valid Does anyone know a way round this? Any help would be appreciated&n...

Error:Cast from type 'DBNull' to type 'Date' is not valid
I tried to insert a null date of birth value to SQL Server table, the datatype is smalldatetime in the table.  I found it insert 1/1/1900 instead of null value.  So I am trying to fix it by the following way: In the first .aspx page, I stored DOB in a session value:  If txtDOB.Text = Nothing Then    Session("DOB") = DBNull.Value Else    Session("DOB") = txtDOB.Text End If In the 2nd .aspx page, I get the value by:  Dim Birthday As Date = CDate(Session("DOB")) However, I got an error message :System.InvalidCastException: Cast fro...

Web resources about - Type Mismatch field 'EventDate' expecting: Date actial:Widestring - embarcadero.delphi.firedac

Resources last updated: 11/26/2015 3:55:59 AM