Forum > Databases
TPQConnection (Postgresql) access violation error on remote database
(1/1)
Sakkie:
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.
--- End quote ---
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 [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---PQConnection1.Connected := False;
OS: Windows 10
FPC: 3.2.2
Lazarus: 3.6
five:
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:
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:
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?
Sakkie:
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.
Navigation
[0] Message Index