Database Insert is Inserting but Throwing an Error

Wappler Version: 5.0.2
Operating System: Windows 11 to develop (local) and Windows Server 2019 Standard (remote)
Server model: .NET
Database: MySQL/MariaDB

Expected behaviour

What do you think should happen?

A record should be added to the database using a simple form and no error generated as per:
https://docs.wappler.io/t/insert-database-record/2863

Actual behaviour

What actually happens?

A record is inserted into the database but a 500 error is generated immediately after

How to reproduce

Try it out on the test page here:
https://carpetshopnortheast.com/formtest.aspx

Notes:
Wappler is reporting that both database connections are working fine (one in Globals->Database Connections and the other in Database Manager-> direct connection)

In the error console, I can see the following error was created as the Inner Exception: ‘Arithmetic operation resulted in an overflow

I’ve spent days on this, including re-installing Wappler and restarting a new project, I’ve even tested on a different domain with a fresh database - all to no avail.

The database table has the following column datatypes:
testid - INT
name VARCHAR 50
email VARCHAR 50
created DATETIME

  • I’ve tried the form without that ‘DATETIME’ field included and I still get the same problem.

My API steps look like this:

My APP structure looks like this:

This should be an absolute doddle of a job but it’s clearly not working correctly. Can anyone out there let me know if it’s a bug or not…?

Wappler uses NodeJS internally for the database connections, on the server it uses the drivers that are installed there. With a Google search it seems there are many bugs with this error message, in most cases it seems to be related with the ODBC Driver, make sure you have the latest version installed on your server.

1 Like

I’ve got the latest driver, I’ve also tried a variety of drivers, all give the same errors. It works fine on PHP server model, it also works fine on Dreamweaver (hate mentioning that here but its a fact). Wappler is also telling me the connections are ‘OK’.

If the error message was less ambiguous it’d make it easier to debug, at the moment this is impossible to debug. It’s very frustrating as the records are being added to the database yet the 503 is still being generated and Wappler says the connections are fine when it’s clearly not, surely this has to be a Wappler bug and not a driver fault?.

I will investigate this further, I know the error happens on the ExecuteScalar method. It doesn’t happen on other queries it seems, the insert does actually do 2 queries, first it does the insert statement and then it does a query to get the identity value. The query for that is SELECT LAST_INSERT_ID() and on executing this query it fails.

Can you tell me what kind of field the primary key is?

The primary key is INT with a length of 11 and autoincrement

As this is a test database there’s no problem at all for me to give you the log in credentials to it, just PM if you need to.

I ran the above query on the test table and it returned a value of ‘0’ - this doesnt seem correct?

What is the exact database you are using? MySQL or MariaDB and which version.

We’re running MariaDB v10.6.8

Could you try setting Enable 32-bit applications to true in the server app pool where your app is running.

Upgrade to 4.0 - “Arithmetic operation resulted in an overflow Error” - MySQL driver issue (microsoft.com)

I’m not able to reproduce the problem, so it is probably some configuration or driver problem. The error is very generic and difficult to determine what the exact cause is.

1 Like

You, my friend, are a genius :slight_smile:

It appears it wasn’t the ODBC driver but the 32bit applications fix that you mentioned which solved this issue.

Enabling 32-bit applications to True on the application pool of the site in question fixed the problem. Phew.!

I’ve carried out some basic testing and everything is now working exactly as it should - thank you for taking the time to look into this. I’m sure this will also help others out there so all this work from both of us wasn’t in vain.

Right, I’m off now to lock myself in my office and get cracking with some code…