0

I'm refactoring an existing Delphi VCL application, migrating the underlying DB from Access 97 (!!) to SQL Server 2014. In the process, we decided for a table to change some field definitions, in particular we changed the field 'Ora' type from DateTime to int.

I have a TADOQuery on the form, that simply does

SELECT * FROM Carichi

After changing the 'Carichi' table definition, I deleted all the Fields from the TADOQuery and ran "Add Fields" to add refreshed fields. Now I can see the 'Ora' Field is a TIntegerField.

But when I run the form, the following exception appears:

06/03/2018 11:00:56:qcarichi: Type mismatch for field 'ora', expecting: Integer actual: DateTime: 

It looks like somewhere the old field type is kept and checked for.

I also tried to completely delete the TADOQuery object from the form and re-insert it from scratch.... no way.... Any suggestions ?

Stefano Losi
  • 719
  • 7
  • 18
  • Do you use DB aware controls, like e.g. `TDBGrid` where would you left misdefined column? – Victoria Mar 06 '18 at 10:21
  • 2
    Sorry but I found the problem (so trivial that I'm quite ashamed here...) At design time I had a connection on the new DB, but I discovered in the code that the DB connection string was forced to the old DB.... Unfortunately this is not an application written by me, so I overlooked that part of code.... – Stefano Losi Mar 06 '18 at 10:21
  • _I discovered in the code that the DB connection string was forced to the old DB_ - has to be that, because the e.message says your field object is looking integer but the **database** is sending datetime: Your TField object is correctly defined. – Vector Mar 06 '18 at 22:30

1 Answers1

0

At design time I had a connection on the new DB, but I discovered in the code that the DB connection string was forced to the old DB, because the e.message says your field object is looking integer but the database is sending datetime: Your TField object is correctly defined.


Compilation of the comments by Stefano Lossi and Vector.

Adriaan
  • 17,741
  • 7
  • 42
  • 75