MSSQL Invalid precision value / NEW 2025!

Hello YouAll,

I know this topic has already been discussed in the past.
I (hopefully) read all the posts here and at Microsofts and tried whatever solution was mentioned (see below).
Unfortunately nothing helped.

An apology forwarded - some of the informational stuff (screenshots etc) is German cause I'm German.

Problem:
In this part of code "FObjMgr.Save(konfig);" produces the exception:

konfig := TKonfig.Create;
konfig.Name := ceKategorie.Text;
FObjMgr.Save(konfig);
idKonfig := konfig.idKonfig;
Screenshot Errormessage on Manager.Save(konfig)

Background Code ...
Entitiy TKonfig.txt (2.3 KB)
... and database table ...
ScreenshotTable Konfig
... and environment:
Delphi 12 Update 2

Here is what I already tried (based on older posts ):

  1. Changed type of "Wert" from 'Text' to 'Varchar(max).
  2. Changed type of "Wert" to 'Varchar(100).
  3. Updated SQL ODBC driver
    as "SQL Server Native Client" is called 'outdated' by Microsoft.
  4. Application is Windows 64bit, tried as Windows 32bit.

I'm running out of ideas ...
Any suggestions anyone?

Regards Kai

Hi @Lahann_Kai,

What happens if you try to use SQL Server Native Client? Does it work?

Why do you know the Wert field is causing the issue?

As you might have probably seen in the other topics, we could never reproduce such issue at our side. Are you able to do so in a clean environment and if yes, could you help us reproduce the issue? Things we need:

  1. Windows version
  2. MS SQL client driver type and version
  3. MS SQL Server version
  4. MS SQL database
  5. Delphi application used to reproduce the issue
  6. Steps to follow to reproduce the issue.

Any help is appreciated.

Hi @wlandgraf,
thank you for the quick answer.

Here are answers to your questions:

  1. What happens if you try to use SQL Server Native Client? Does it work?
    Which version, Client is outdated by MS
    Nativer SQL Server-Client - SQL Server Native Client | Microsoft Learn
  2. Why do you know the Wert field is causing the issue?
    Just an idea based on the older issues ...
  3. Things you need:
    Windows:
Edition Windows 11 Pro
Version 24H2
Installiert am ‎11.‎01.‎2025
Betriebssystembuild 26100.2894
Leistung Windows Feature Experience Pack 1000.26100.36.0

MS SQL client driver type and version
As mentioned in topic


MS SQL Server version
Screenshot SQL-Server
MS SQL database
ldg.sql.txt (15.4 KB)
Delphi application used to reproduce the issue and Steps to follow to reproduce the issue.

  1. Connect to Database
  2. Execute this code:
    konfig := TKonfig.Create;
    konfig.Name := ceKategorie.Text;
    konfig.Kategorie := nil;
    FObjMgr.Save(konfig);
    idKonfig := konfig.idKonfig;

Sorry, I forgot to mention:
I changed the unit "Aurelius.Drivers.MSSQL" for the new Driver:

procedure AddMSSQLDrivers;
begin
MSSQLOdbcDrivers := TArray.Create(
'ODBC Driver 18 for SQL Server',
'ODBC Driver 17 for SQL Server',
'ODBC Driver 13.1 for SQL Server',
'ODBC Driver 13 for SQL Server',
'ODBC Driver 11 for SQL Server',
'SQL Server Native Client 11.0',
'SQL Server Native Client 10.0',
'SQL Native Client',
'SQL Server'
);
end;

Thanks, I only miss the Delphi application you use (source code). Ideally a full compilable test application, but at the very least the Aurelius mapped entities, including TKonfig class.

The Aurelius mapped entity TKonfig class can be found in my opening message:
image

But here is a test project:
test.zip (36.0 KB)
How to test:
Log into Database:

[Datei|Anmelden...]
"Anmelden"

Open dialog "Konfiguration":

[Datei|Einstellungen|Konfiguration...]

Type text in field "Kategorie" and exit the field ...
image

BTW: Updating a record via the dataset works.

I found out something interessting:
The error occurs only if one of the varchar fields (name,wert) is an empty string. Setting both fields to <>'' it works.
This is true for inserting and updating records.

Except when I change 'wert' to varchar(max), then both operations result in an error again.

May be this helps`?

Meanwhile I changed from MSSQL driver to FDAC MSSQL Adapter,
that works for me at the moment but I'd prefer the native driver ...

Thank you very much for the detailed information. With it we were able to reproduce the problem, it has been fixed. Next version will address this issue.

1 Like

Thank you. :+1: