Recent

Author Topic: TPQConnection (Postgresql) access violation error on remote database  (Read 710 times)

Sakkie

  • Newbie
  • Posts: 5
  • One love
I get the following error when closing TPQConnection (Postgresql) to a REMOTE DATABASE during DEBUGGING (on Lazarus IDE):

Quote
Project X raised exception class 'External: ACCESS VIOLATION' with message: Access violation executing address $00007FFA1466BA70.

This error DOES NOT HAPPEN when debugging and the connection is to a LOCAL database. Also, it DOES NOT HAPPEN when RUNNING (not debugging) the application REGARDLESS of whether the connection is to a LOCAL OR REMOTE DATABASE.

Following is the code that raises the exception:
Code: Pascal  [Select][+][-]
  1. PQConnection1.Connected := False;

OS: Windows 10
FPC: 3.2.2
Lazarus: 3.6


five

  • New Member
  • *
  • Posts: 28
Re: TPQConnection (Postgresql) access violation error on remote database
« Reply #1 on: November 12, 2024, 05:57:00 pm »
Hi Sakkie

Things you need to check :

  • PQConnection1.Connected property in design mode is it set to True or False? It should be set to false in design mode and set it to true in your code after setting all the others connection parameters
  • The exception is not showing in runtime, do you have a Try Except End that not raising the exception?

Sakkie

  • Newbie
  • Posts: 5
  • One love
Re: TPQConnection (Postgresql) access violation error on remote database
« Reply #2 on: November 21, 2024, 01:06:33 pm »
Hi five  ;)

Firstly, apologies for not responding sooner.

Yes, the Connected property is set to false and all the connection parameter values are assigned in OnShow. The odd thing is that setting the Connected property to true and retrieving data from the database works fine. The problem arises when setting it to false at the end (it really baffles me).

No, I don't have the Try Except End to handle setting the Connected property to false, so the application should fail in runtime but it doesn't. However, your question triggered me to use it to see if I might get a clearer error message but that didn't work as this is a memory access error, i.e. the same error comes up.

five

  • New Member
  • *
  • Posts: 28
Re: TPQConnection (Postgresql) access violation error on remote database
« Reply #3 on: November 21, 2024, 01:25:51 pm »
Hi Sakkie,

Becarefull on the sequence order of the component destruction when you are closing your application, where / on witch event in your code you are invoking this line "PQConnection1.Connected := False;" ?
A suggestion, did you try to put a button and close the connection after retrieving data from the database on the onclick event, what happen?
« Last Edit: November 21, 2024, 01:32:10 pm by five »

Sakkie

  • Newbie
  • Posts: 5
  • One love
Re: TPQConnection (Postgresql) access violation error on remote database
« Reply #4 on: November 21, 2024, 03:40:15 pm »
Everything is happening in the code of the OnClick event of a button, i.e. connecting to the database, retrieving the data, and disconnecting from the database. I hope that answers your question.

 

TinyPortal © 2005-2018