Runtime error 216 while destroying connection

Forum related to version 6.5.1 (alpha) and 6.6.x (beta) of ZeosLib's DBOs

Moderators: gto, cipto_kh, EgonHugeist

Post Reply
law
Fresh Boarder
Fresh Boarder
Posts: 8
Joined: 28.12.2006, 15:12
Location: Eger
Contact:

Runtime error 216 while destroying connection

Post by law »

Running a query in TZQuery without Application.Run in the project source cause Runtime error 216. See the uploaded demo project.
You do not have the required permissions to view the files attached to this post.
User avatar
mdaems
Zeos Project Manager
Zeos Project Manager
Posts: 2766
Joined: 20.09.2005, 15:28
Location: Brussels, Belgium
Contact:

Post by mdaems »

Well,

The way you wrote this doesn't look very nice, I think. I'm not a real experienced Delphi writer, but I think you should call Application.Run to be able to process exceptions thrown by the application. (That seems to be the place where the Runtime error is Thrown.) Too prove this I added a procedure to TDM that raises an exception and called that instead of DM.q.Open; That also causes a runtime exception.

My advice : use application.Run and do a Application.terminate when opening the connection fails in your form or the data module.

Mark
law
Fresh Boarder
Fresh Boarder
Posts: 8
Joined: 28.12.2006, 15:12
Location: Eger
Contact:

Post by law »

Yes, it doesn't look very nice. I wrote it to log in users to the application. This method worked perfectly in D4 with BDE. I rewrote this part of my code, placed the log in code to MainForm.FormShow, but the form shows then closes if the user click cancel on log in form. It doesn't look very nice too.
In the sample program, access violation caused by TZConnection.Disconnect in line FConnection.Close. FConnection is not nil, so I can't understand why there's an av.
Any other programs work fine with this method in project source.

Anyway, I solved my problem, thanks for your advice.
Post Reply