#1 2021-12-06 15:23:01

larand54
Member
Registered: 2018-12-25
Posts: 104

Cannot insert from RestServer

I have a small project here where I included everything in one program because it only is about updating a single file with a text field.
My problem is that when the server tries to add a record I'll get an error which says in short: "Cannot insert explicit value into ----- when IDENTITY_INSERT is set to OFF"

I'm running Delphi11 and MSSQL.

Links to part of the code: [URL https://1drv.ms/u/s!AkzgaKIeNifrhaQI3gC … A?e=SpWAz3 /url]

the error message: [URL https://1drv.ms/u/s!AkzgaKIeNifrhaQLwLN … w?e=02zydi /url]


Delphi-11, WIN10

Offline

#2 2021-12-06 16:07:32

ab
Administrator
From: France
Registered: 2010-06-21
Posts: 14,659
Website

Re: Cannot insert from RestServer

This is a MSSQL specific question, very tied to the database itself.

Did you create the table with mORMot? I guess not.

Check the generated and executed SQL to find out where the problem comes from.

Why do you use fDBSever.Commit without any BeginTransaction?
It is not correct. Just make the Add or Update directly.

Also note that your code is leaking memory - e.g. the user: TSQLRecUsers is never freed.

Offline

#3 2021-12-06 16:20:03

larand54
Member
Registered: 2018-12-25
Posts: 104

Re: Cannot insert from RestServer

Sorry, I fixed it by deleting the table and then run the program again. But Yes I created the table with mORMot but I also have tested different Restservers and it might have been created different then.
I tested TSQLRestClientDB but could not understand how I should set it up. As I don't use SQLITE this time I could not put a filename into the third parameter, I did try but then it created a db3-file with some strange marks ('v') on the tables.


Delphi-11, WIN10

Offline

Board footer

Powered by FluxBB