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 » Unexpected crash on MSSQLSession Close()
Unexpected crash on MSSQLSession Close() [message #52611] Tue, 29 October 2019 11:38 Go to next message
Giorgio is currently offline  Giorgio
Messages: 218
Registered: August 2015
Experienced Member
Hi there,
I have a MS SQL Server database (not managed by me) and I've been integrating it in my application. I just pull some data and put them in my database (PostGreSQL). In my class I open the connection, send the proper query and deliver the data to another class (using ValueMaps) that save them in my db. The destructor of the class that queries MS SQL is has follows:

MssqlDAO::~MssqlDAO(){

  if(cbdb.IsOpen()) //cddb is the session declared as "MSSQLSession cbdb;" in the header file
    cbdb.Close();
}


This sometimes (not every time) leads to unexpected crash. I have no clue, because the code is fairly easy and should run. I tried to add a Sleep(1000) before Close(), but with no luck.

Has anyone an idea on this?

Thanks,
giorgio
Re: Unexpected crash on MSSQLSession Close() [message #52612 is a reply to message #52611] Tue, 29 October 2019 19:35 Go to previous messageGo to next message
mirek is currently offline  mirek
Messages: 13975
Registered: November 2005
Ultimate Member
Giorgio wrote on Tue, 29 October 2019 11:38
Hi there,
I have a MS SQL Server database (not managed by me) and I've been integrating it in my application. I just pull some data and put them in my database (PostGreSQL). In my class I open the connection, send the proper query and deliver the data to another class (using ValueMaps) that save them in my db. The destructor of the class that queries MS SQL is has follows:

MssqlDAO::~MssqlDAO(){

  if(cbdb.IsOpen()) //cddb is the session declared as "MSSQLSession cbdb;" in the header file
    cbdb.Close();
}


This sometimes (not every time) leads to unexpected crash. I have no clue, because the code is fairly easy and should run. I tried to add a Sleep(1000) before Close(), but with no luck.

Has anyone an idea on this?

Thanks,
giorgio


Please check that there are no active Sql instances connected to that session...

Mirek
Re: Unexpected crash on MSSQLSession Close() [message #52620 is a reply to message #52612] Wed, 30 October 2019 11:59 Go to previous message
Giorgio is currently offline  Giorgio
Messages: 218
Registered: August 2015
Experienced Member
mirek wrote on Tue, 29 October 2019 19:35

Please check that there are no active Sql instances connected to that session...

Mirek


I added a commit to be sure all connections will be closed, and it seems fixed now:

MssqlDAO::~MssqlDAO(){
  if(cbdb.IsOpen()){

    cbdb.Commit();
    cbdb.Close();
  }
}


Is there a better way to check that (I tried FlushConnections() and SessionClose() but they are private or protected)?
Previous Topic: undefined symbol when linking pgexec mingw
Next Topic: sql innerjoin not working
Goto Forum:
  


Current Time: Thu Mar 28 13:13:10 CET 2024

Total time taken to generate the page: 0.00873 seconds