Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ SQL » ODBC Assertion failed
Re: ODBC Assertion failed [message #56115 is a reply to message #56113] Thu, 28 January 2021 09:38 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13986
Registered: November 2005
Ultimate Member
Any chance for a testcase? I would not want to let this go...
Re: ODBC Assertion failed [message #56237 is a reply to message #56115] Fri, 12 February 2021 18:15 Go to previous messageGo to next message
Giorgio is currently offline  Giorgio
Messages: 218
Registered: August 2015
Experienced Member
I will prepare indeed a testcase, I have just to find some spare time in this crazy time of the pandemic.
Re: ODBC Assertion failed [message #57080 is a reply to message #56237] Fri, 21 May 2021 11:04 Go to previous messageGo to next message
Giorgio is currently offline  Giorgio
Messages: 218
Registered: August 2015
Experienced Member
Hello,
I'm preparing the testcase, it's harder than I thought as I have to strip down a quite big software, I'll upload the testcase next week.
Regards,
gio
Re: ODBC Assertion failed [message #57092 is a reply to message #55812] Mon, 24 May 2021 14:54 Go to previous messageGo to next message
Giorgio is currently offline  Giorgio
Messages: 218
Registered: August 2015
Experienced Member
Hi there,
so, here's my test case.

The basic functioning of the test case is the following: an object of the class Order is created (there is a in the test case class that creates a fake order, in my application the order is entered by the user through a UI), the order is then converted in a ValueMap and finally is inserted in the DB using SqlIds and other facilities provided by U++. I use this database connection to integrate my application with an accounting software. This accounting software provides a special table of tye database to allow other software to insert data in it (i.e. I'm using the table of the accounting software for their designed purpose).

I'll try now to go through each class to explain the goal of each one.

The class Order (alongside with the class OrderRow) represents a customer order: it has the classic header/body structure.

The file TesDbSql.h contains definitions of the SqlIds used by Upp's Sql class (for insert etc.).

The class TestDAO contains the actual functions that save data into the database.

The class TestDocumentMapping transform an Order object into a ValueMap, so it can be easily processed by the DAO.

The CreateOrder class creates a fake order.

The util class contains some functions that I use to convert the Order object into a ValueMap.

Finally the Db.sql file contains the script used to create the test database.

The crash happens only when the application is compiled, not in debug mode. With the real ms sql database the behaviour is really "consistent": I can insert one order without problems, but, if I try to insert a second one immediately after I inserted the first, the application crashes. With the database included in my test case the behaviour is much more erratic. I noticed however that there are some patterns: if I enter some orders with the application, exits the application, delete the content of the tables in the db and then launch the application and insert an order again, the application usually crashes. It usually crashes even if I insert some orders, exit the application, launch it again and insert some new orders.

If you have additional question let me know.
Regards,
gio
Re: ODBC Assertion failed [message #57104 is a reply to message #56115] Tue, 25 May 2021 17:16 Go to previous messageGo to next message
Giorgio is currently offline  Giorgio
Messages: 218
Registered: August 2015
Experienced Member
Hi,
I created the test case here.
Regards,
gio
Re: ODBC Assertion failed [message #57194 is a reply to message #57104] Tue, 08 June 2021 10:08 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13986
Registered: November 2005
Ultimate Member
Giorgio wrote on Tue, 25 May 2021 17:16
Hi,
I created the test case here.
Regards,
gio


You seem to set

test_db.ThrowOnError();

but nowwhere I can see any catches for Sql exception. As provided, it tends to err on duplicate keys, which without catches to Sql errors leads to aborting the app. Can that be a reason?

After commenting out above line, all works as expected, no crashes....

(OK, I think there will be more, but this where I got for now testing your testcase...)

Mirek

[Updated on: Tue, 08 June 2021 10:08]

Report message to a moderator

Re: ODBC Assertion failed [message #57202 is a reply to message #57194] Thu, 10 June 2021 17:00 Go to previous message
Giorgio is currently offline  Giorgio
Messages: 218
Registered: August 2015
Experienced Member
Hi there,
I finally found the culprit: that was a very tricky one.

So, in my code, I had the following in the connection string:

"Driver={SQL Server}"

I used that after checking the driver available in my system using ODBC Data sources:

https://imgur.com/Qeez2OA

For some reason that driver is not working (AFAIK because it's a 32 bit and I compile my application in 64 bit). Using the driver {ODBC Driver 17 for SQL Server} everything works fine. Anyway the application was able to insert the data into the DB before crashing, so it was really hard to tell that the problem was the driver. I used Upp with Mysql, Postgres and SqlLite and never had such a problem, so I blame Microsoft.

Thanks for the support!
gio
Previous Topic: OleDBSession in Archive
Next Topic: sqlite3 Custom Function in SqlExp
Goto Forum:
  


Current Time: Fri Jun 21 22:09:03 CEST 2024

Total time taken to generate the page: 0.01367 seconds