Form_Terminate is not working?????
Dear Sir,
I've code to close the database connection in the Form_Terminate() event. But as I exit the system by clicking at the 'X' button on the up-right corner, the system is still running at the background. I need to open the task manager to terminate the whole system.
Is there any way to solve this?
Thanks...:-)
Re: Form_Terminate is not working?????
yea happened to me also ,instead of unloading the main form and ending the application,i unloaded the main form then loaded the login form and unloaded the login form ,this way i got rid of that strange problem(actually i have a login form ,after which the main mdiform is shown).
hope that will give u some idea
Re: Form_Terminate is not working?????
Use the Form_QueryUnload event.
Re: Form_Terminate is not working?????
i tried that too ,still the problem dint get sorted out.i think the adodc connections take time to terminate and the form gets unloaded before that!!
Re: Form_Terminate is not working?????
But in the QueryUnload event are you closing and destroying the recordsets and connections?
Re: Form_Terminate is not working?????
yea exactly .but it was saying "memory exception ,could not write to refernced memory at address ....some crap,"
so i unloded my main mdi(and all child forms),then loaded the login form and unloaded it to gracefully exit from the system.
Re: Form_Terminate is not working?????
Oh an MDI app then yes you need to handle it differently like you did. But for the thread starter if its a regular form app then the QueryUnload event will work just fine.
Re: Form_Terminate is not working?????
add a end word in your form_terminate()
i sugest that you create a function in which you will close all connection and end your system and just call this up when ever you terminate or you want to close your application
Re: Form_Terminate is not working?????
There is almost no valid use for the "End" command unless you have a app that only uses modules. End is considered bad progframming practive to "fix" some other issue.
Re: Form_Terminate is not working?????
i said that before issuing the end command, you may want to dispose all the objects you used specially on connections. end will kill your process at all.
Re: Form_Terminate is not working?????
Yes, I know, but its still bad practice even if you do perform a "clean up" first. :)
Re: Form_Terminate is not working?????
people really thinks end is a bad practice but they are missing the point here. End will clear your entry in the Processes of the window thus allowing more mem for other apps. it is not really a bad practice since you will free up what you have used. if you just used a simple close then you will leave something hanging for that instance.
Re: Form_Terminate is not working?????
Well its a very debatable topic and has been posted many times on the forums already but you could argue that if you write your code correctly then you wouldnt need to use End. ;)
Re: Form_Terminate is not working?????
it is a safety measure for some reason like on severe error occurance
Re: Form_Terminate is not working?????
Well I can honestly say that I have never used End in any of my apps since becoming fluent in VB several years ago. I dont want to go too far off topic but perhaps a search for the past threads would be better if you want more info on why not to use it. :)