Runtime error 216 while destroying connection
Moderators: gto, cipto_kh, EgonHugeist
Runtime error 216 while destroying connection
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.
- mdaems
- Zeos Project Manager
- Posts: 2766
- Joined: 20.09.2005, 15:28
- Location: Brussels, Belgium
- Contact:
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
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
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.
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.